├── Makefile ├── README ├── btspp.c ├── btspp.xml ├── profile1-iface.c └── profile1-iface.h /Makefile: -------------------------------------------------------------------------------- 1 | 2 | CFLAGS_DBUS = $(shell pkg-config --cflags --libs dbus-1) 3 | CFLAGS_DBUS_GLIB = $(shell pkg-config --cflags --libs dbus-glib-1) 4 | CFLAGS_GIO = $(shell pkg-config --cflags --libs gio-2.0) 5 | CFLAGS_GIO_UNIX = $(shell pkg-config --cflags --libs gio-unix-2.0) 6 | 7 | CFLAGS = -g -Wall -Werror 8 | 9 | all: btspp 10 | 11 | btspp: btspp.c profile1-iface.h profile1-iface.c 12 | gcc $^ -o $@ $(CFLAGS) $(CFLAGS_DBUS) $(CFLAGS_DBUS_GLIB) $(CFLAGS_GIO) $(CFLAGS_GIO_UNIX) 13 | 14 | clean: 15 | rm -f btspp 16 | 17 | .PHONY: all clean 18 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This is an example Bluetooth Serial Port Profile client and server 2 | application which uses bluez 5.x to exercise the Bluetooth Serial 3 | Port Profile (1.2). 4 | 5 | To run as a server, just invoke from the command-line using 'sudo' and 6 | no arguements. 7 | 8 | To run as a client, adding any string after the command name will trigger 9 | this mode. 10 | 11 | First, the application registers itself to bluez using the ProfileManager1's 12 | RegisterProfile method. It will indicate to bluez what role it's playing 13 | (client or server). If run as server, this will cause the BT controller to 14 | list the Serial Port profile when the bluetoothctl 'show' command is run. 15 | Likewise, from a remote device, the bluetootctl 'info' command will also show 16 | the Serial Port profile listed for the device. When run a client, the Serial 17 | Port profile will not be listed on either side. 18 | 19 | When a connection is triggered on the client, bluez will call the NewConnection 20 | method and pass an active Bluetooth RFCOMM socket which then can be used to 21 | write data to the server. On the server side, if the client device is paired, 22 | but trusted, then the default agent needs to be configured (eg. agent on, 23 | default-agent), and if so, a prompt will be displayed asking an admin to 24 | confirm the incoming server request. 25 | 26 | If trusted, or an admin confirms the service request, then the server's 27 | NewConnection method will be called with a fd representing the other end of 28 | the BT socket. 29 | 30 | In the current implementation, the IO is done very simply with read/write calls. 31 | Also, the server explicitly sets the socket to blocking mode to simplify the 32 | code. When boths sides complete their IO, the application exits. 33 | 34 | To trigger the connection from client to server, the following dbus-send 35 | command can be used: 36 | 37 | $ sudo dbus-send --system --print-reply --dest=org.bluez \ 38 | /org/bluez/hciX/dev_XX_YY_ZZ_AA_BB_CC \ 39 | org.bluez.Device1.ConnectProfile \ 40 | string:"00001101-0000-1000-8000-00805f9b34fb" 41 | 42 | * hciX - replace X with controller index (eg. hci0) 43 | * dev_XX_YY_ZZ_AA_BB_CC - replace with server's BT control MAC address 44 | 45 | -------------------------------------------------------------------------------- /btspp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Canonical Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #include "profile1-iface.h" 32 | 33 | #define SERIAL_PORT_PROFILE_UUID "00001101-0000-1000-8000-00805f9b34fb" 34 | 35 | typedef struct { 36 | uint8_t b[6]; 37 | } __attribute__((packed)) bdaddr_t; 38 | 39 | struct sockaddr_rc { 40 | sa_family_t rc_family; 41 | bdaddr_t rc_bdaddr; 42 | uint8_t rc_channel; 43 | }; 44 | 45 | struct spp_data { 46 | GMainLoop *loop; 47 | int sock_fd; 48 | gboolean server; 49 | struct sockaddr_rc local; 50 | struct sockaddr_rc remote; 51 | }; 52 | 53 | int register_profile(struct spp_data *spp, GDBusProxy *proxy) 54 | { 55 | GVariant *profile; 56 | GVariantBuilder profile_builder; 57 | GError *error = NULL; 58 | 59 | printf("register_profile called!\n"); 60 | 61 | g_variant_builder_init(&profile_builder, G_VARIANT_TYPE("(osa{sv})")); 62 | 63 | if (g_variant_is_object_path("/bluetooth/profile/serial_port")) { 64 | printf("object path is good!\n"); 65 | } 66 | 67 | g_variant_builder_add (&profile_builder, "o", 68 | "/bluetooth/profile/serial_port"); 69 | 70 | g_variant_builder_add (&profile_builder, "s", SERIAL_PORT_PROFILE_UUID); 71 | 72 | g_variant_builder_open(&profile_builder, G_VARIANT_TYPE("a{sv}")); 73 | 74 | // not specifying AutoConnect... 75 | 76 | g_variant_builder_open(&profile_builder, G_VARIANT_TYPE("{sv}")); 77 | g_variant_builder_add (&profile_builder, "s", "Channel"); 78 | g_variant_builder_add (&profile_builder, "v", g_variant_new_uint16(22)); 79 | g_variant_builder_close(&profile_builder); 80 | 81 | g_variant_builder_open(&profile_builder, G_VARIANT_TYPE("{sv}")); 82 | g_variant_builder_add (&profile_builder, "s", "Service"); 83 | g_variant_builder_add (&profile_builder, "v", 84 | g_variant_new_string(SERIAL_PORT_PROFILE_UUID)); 85 | g_variant_builder_close(&profile_builder); 86 | 87 | g_variant_builder_open(&profile_builder, G_VARIANT_TYPE("{sv}")); 88 | g_variant_builder_add (&profile_builder, "s", "Name"); 89 | g_variant_builder_add (&profile_builder, "v", 90 | g_variant_new_string("Serial Port")); 91 | g_variant_builder_close(&profile_builder); 92 | 93 | g_variant_builder_open(&profile_builder, G_VARIANT_TYPE("{sv}")); 94 | g_variant_builder_add (&profile_builder, "s", "Role"); 95 | 96 | if (spp->server) { 97 | g_variant_builder_add (&profile_builder, "v", 98 | g_variant_new_string("server")); 99 | } else { 100 | g_variant_builder_add (&profile_builder, "v", 101 | g_variant_new_string("client")); 102 | } 103 | 104 | g_variant_builder_close(&profile_builder); 105 | 106 | 107 | g_variant_builder_close(&profile_builder); 108 | profile = g_variant_builder_end(&profile_builder); 109 | 110 | g_dbus_proxy_call_sync (proxy, 111 | "RegisterProfile", 112 | profile, 113 | G_DBUS_CALL_FLAGS_NONE, 114 | -1, 115 | NULL, 116 | &error); 117 | g_assert_no_error(error); 118 | 119 | return 0; 120 | } 121 | 122 | gboolean 123 | server_read_data (gpointer user_data) { 124 | char buf[1024] = { 0 }; 125 | int bytes_read; 126 | int opts = 0; 127 | struct spp_data *spp = user_data; 128 | 129 | printf("server_read_data called\n"); 130 | 131 | // set socket for blocking IO 132 | fcntl(spp->sock_fd, F_SETFL, opts); 133 | opts = fcntl(spp->sock_fd, F_GETFL); 134 | if (opts < 0) { 135 | perror("fcntl(F_GETFL)"); 136 | exit(EXIT_FAILURE); 137 | } 138 | 139 | opts &= ~O_NONBLOCK; 140 | 141 | if (fcntl(spp->sock_fd, F_SETFL,opts) < 0) { 142 | perror("fcntl(F_SETFL)"); 143 | exit(EXIT_FAILURE); 144 | } 145 | 146 | // read data from the client 147 | bytes_read = read(spp->sock_fd, buf, sizeof(buf)); 148 | if ( bytes_read > 0 ) { 149 | printf("received [%s]\n", buf); 150 | } else { 151 | printf("error reading from client [%d] %s\n", errno, strerror(errno)); 152 | } 153 | 154 | // close connection 155 | close(spp->sock_fd); 156 | 157 | // all done! 158 | g_main_loop_quit(spp->loop); 159 | 160 | // make this a one-shot 161 | return false; 162 | } 163 | 164 | gboolean 165 | client_write_data (gpointer user_data) { 166 | int status; 167 | struct spp_data *spp = user_data; 168 | 169 | printf("client_write_data called\n"); 170 | 171 | // read data from the client 172 | status = write(spp->sock_fd, "Hello World!", 12); 173 | if (status < 0) { 174 | perror("client: write to socket failed!\n"); 175 | } 176 | 177 | printf("client_write_data status OK!\n"); 178 | 179 | // close connection 180 | close(spp->sock_fd); 181 | 182 | // all done! 183 | g_main_loop_quit(spp->loop); 184 | 185 | // make this a one-shot 186 | return false; 187 | } 188 | 189 | void 190 | print_bdaddr (gchar *prefix, const bdaddr_t *bdaddr) 191 | { 192 | printf ("%s: ", prefix); 193 | 194 | // print BTADDR in reverse 195 | for (int i = 5; i > -1; i--) { 196 | printf("%02X", bdaddr->b[i]); 197 | } 198 | 199 | printf ("\n"); 200 | } 201 | 202 | static gboolean 203 | on_handle_new_connection (OrgBluezProfile1 *interface, 204 | GDBusMethodInvocation *invocation, 205 | const gchar *device, 206 | const GVariant *fd, 207 | const GVariant *fd_props, 208 | gpointer user_data) 209 | { 210 | GDBusMessage *message; 211 | GError *error = NULL; 212 | GUnixFDList *fd_list; 213 | socklen_t optlen; 214 | struct sockaddr_rc saddr; 215 | struct spp_data *spp = user_data; 216 | 217 | message = g_dbus_method_invocation_get_message (invocation); 218 | fd_list = g_dbus_message_get_unix_fd_list (message); 219 | spp->sock_fd = g_unix_fd_list_get (fd_list, 0, &error); 220 | g_assert_no_error (error); 221 | 222 | printf ("handle_new_conn called for device: %s fd: %d!\n", device, spp->sock_fd); 223 | 224 | memset(&saddr, 0, sizeof(saddr)); 225 | optlen = sizeof(saddr); 226 | 227 | if (getsockname (spp->sock_fd, (struct sockaddr *) &(spp->local), &optlen) < 0) { 228 | printf("handle_new_conn: local getsockname failed: %s\n", strerror(errno)); 229 | return FALSE; 230 | } 231 | 232 | print_bdaddr("handle_new_conn local: ", &(spp->local.rc_bdaddr)); 233 | 234 | memset(&saddr, 0, sizeof(saddr)); 235 | if (getpeername (spp->sock_fd, (struct sockaddr *) &(spp->remote), &optlen) < 0) { 236 | printf("handle_new_conn: remote getsockname failed: %s\n", strerror(errno)); 237 | return FALSE; 238 | } 239 | 240 | print_bdaddr("handle_new_conn remote: ", &(spp->remote.rc_bdaddr)); 241 | 242 | // finished with method call; no reply sent 243 | g_dbus_method_invocation_return_value(invocation, NULL); 244 | 245 | if (spp->server) { 246 | g_idle_add(server_read_data, spp); 247 | } else { 248 | g_idle_add(client_write_data, spp); 249 | } 250 | 251 | return TRUE; 252 | } 253 | 254 | int main(int argc, char *argv[]) 255 | { 256 | GDBusProxy *proxy; 257 | GDBusConnection *conn; 258 | GError *error = NULL; 259 | OrgBluezProfile1 *interface; 260 | struct spp_data *spp; 261 | 262 | spp = g_new0 (struct spp_data, 1); 263 | 264 | /* TODO: add real command-line handling. Currently any string 265 | * specified on the command-line triggers client mode. This 266 | * is leftover behavior from the legacy rfcomm sample application 267 | * which required the client to know the remote server's MAC addr. 268 | */ 269 | if (argc == 1) { 270 | spp->server = true; 271 | } 272 | 273 | spp->loop = g_main_loop_new (NULL, FALSE); 274 | 275 | conn = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); 276 | g_assert_no_error (error); 277 | 278 | proxy = g_dbus_proxy_new_sync (conn, 279 | G_DBUS_PROXY_FLAGS_NONE, 280 | NULL,/* GDBusInterfaceInfo */ 281 | "org.bluez",/* name */ 282 | "/org/bluez",/* object path */ 283 | "org.bluez.ProfileManager1",/* interface */ 284 | NULL,/* GCancellable */ 285 | &error); 286 | g_assert_no_error (error); 287 | 288 | if (register_profile (spp, proxy)) { 289 | return 0; 290 | } 291 | 292 | interface = org_bluez_profile1_skeleton_new (); 293 | 294 | g_signal_connect (interface, 295 | "handle_new_connection", 296 | G_CALLBACK (on_handle_new_connection), 297 | spp); 298 | 299 | error = NULL; 300 | if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (interface), 301 | conn, 302 | "/bluetooth/profile/serial_port", 303 | &error)) 304 | { 305 | printf ("dbus_interface_skeleton_export failed for SPP!\n"); 306 | return 1; 307 | } 308 | 309 | g_main_loop_run (spp->loop); 310 | 311 | g_object_unref (proxy); 312 | g_object_unref (conn); 313 | 314 | return 0; 315 | } 316 | -------------------------------------------------------------------------------- /btspp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /profile1-iface.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by gdbus-codegen 2.48.2. DO NOT EDIT. 3 | * 4 | * The license of this code is the same as for the source it was derived from. 5 | */ 6 | 7 | #ifdef HAVE_CONFIG_H 8 | # include "config.h" 9 | #endif 10 | 11 | #include "profile1-iface.h" 12 | 13 | #include 14 | #ifdef G_OS_UNIX 15 | # include 16 | #endif 17 | 18 | typedef struct 19 | { 20 | GDBusArgInfo parent_struct; 21 | gboolean use_gvariant; 22 | } _ExtendedGDBusArgInfo; 23 | 24 | typedef struct 25 | { 26 | GDBusMethodInfo parent_struct; 27 | const gchar *signal_name; 28 | gboolean pass_fdlist; 29 | } _ExtendedGDBusMethodInfo; 30 | 31 | typedef struct 32 | { 33 | GDBusSignalInfo parent_struct; 34 | const gchar *signal_name; 35 | } _ExtendedGDBusSignalInfo; 36 | 37 | typedef struct 38 | { 39 | GDBusPropertyInfo parent_struct; 40 | const gchar *hyphen_name; 41 | gboolean use_gvariant; 42 | } _ExtendedGDBusPropertyInfo; 43 | 44 | typedef struct 45 | { 46 | GDBusInterfaceInfo parent_struct; 47 | const gchar *hyphen_name; 48 | } _ExtendedGDBusInterfaceInfo; 49 | 50 | typedef struct 51 | { 52 | const _ExtendedGDBusPropertyInfo *info; 53 | guint prop_id; 54 | GValue orig_value; /* the value before the change */ 55 | } ChangedProperty; 56 | 57 | static void 58 | _changed_property_free (ChangedProperty *data) 59 | { 60 | g_value_unset (&data->orig_value); 61 | g_free (data); 62 | } 63 | 64 | static gboolean 65 | _g_strv_equal0 (gchar **a, gchar **b) 66 | { 67 | gboolean ret = FALSE; 68 | guint n; 69 | if (a == NULL && b == NULL) 70 | { 71 | ret = TRUE; 72 | goto out; 73 | } 74 | if (a == NULL || b == NULL) 75 | goto out; 76 | if (g_strv_length (a) != g_strv_length (b)) 77 | goto out; 78 | for (n = 0; a[n] != NULL; n++) 79 | if (g_strcmp0 (a[n], b[n]) != 0) 80 | goto out; 81 | ret = TRUE; 82 | out: 83 | return ret; 84 | } 85 | 86 | static gboolean 87 | _g_variant_equal0 (GVariant *a, GVariant *b) 88 | { 89 | gboolean ret = FALSE; 90 | if (a == NULL && b == NULL) 91 | { 92 | ret = TRUE; 93 | goto out; 94 | } 95 | if (a == NULL || b == NULL) 96 | goto out; 97 | ret = g_variant_equal (a, b); 98 | out: 99 | return ret; 100 | } 101 | 102 | G_GNUC_UNUSED static gboolean 103 | _g_value_equal (const GValue *a, const GValue *b) 104 | { 105 | gboolean ret = FALSE; 106 | g_assert (G_VALUE_TYPE (a) == G_VALUE_TYPE (b)); 107 | switch (G_VALUE_TYPE (a)) 108 | { 109 | case G_TYPE_BOOLEAN: 110 | ret = (g_value_get_boolean (a) == g_value_get_boolean (b)); 111 | break; 112 | case G_TYPE_UCHAR: 113 | ret = (g_value_get_uchar (a) == g_value_get_uchar (b)); 114 | break; 115 | case G_TYPE_INT: 116 | ret = (g_value_get_int (a) == g_value_get_int (b)); 117 | break; 118 | case G_TYPE_UINT: 119 | ret = (g_value_get_uint (a) == g_value_get_uint (b)); 120 | break; 121 | case G_TYPE_INT64: 122 | ret = (g_value_get_int64 (a) == g_value_get_int64 (b)); 123 | break; 124 | case G_TYPE_UINT64: 125 | ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b)); 126 | break; 127 | case G_TYPE_DOUBLE: 128 | { 129 | /* Avoid -Wfloat-equal warnings by doing a direct bit compare */ 130 | gdouble da = g_value_get_double (a); 131 | gdouble db = g_value_get_double (b); 132 | ret = memcmp (&da, &db, sizeof (gdouble)) == 0; 133 | } 134 | break; 135 | case G_TYPE_STRING: 136 | ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0); 137 | break; 138 | case G_TYPE_VARIANT: 139 | ret = _g_variant_equal0 (g_value_get_variant (a), g_value_get_variant (b)); 140 | break; 141 | default: 142 | if (G_VALUE_TYPE (a) == G_TYPE_STRV) 143 | ret = _g_strv_equal0 (g_value_get_boxed (a), g_value_get_boxed (b)); 144 | else 145 | g_critical ("_g_value_equal() does not handle type %s", g_type_name (G_VALUE_TYPE (a))); 146 | break; 147 | } 148 | return ret; 149 | } 150 | 151 | /* ------------------------------------------------------------------------ 152 | * Code for interface org.bluez.Profile1 153 | * ------------------------------------------------------------------------ 154 | */ 155 | 156 | /** 157 | * SECTION:OrgBluezProfile1 158 | * @title: OrgBluezProfile1 159 | * @short_description: Generated C code for the org.bluez.Profile1 D-Bus interface 160 | * 161 | * This section contains code for working with the org.bluez.Profile1 D-Bus interface in C. 162 | */ 163 | 164 | /* ---- Introspection data for org.bluez.Profile1 ---- */ 165 | 166 | static const _ExtendedGDBusMethodInfo _org_bluez_profile1_method_info_release = 167 | { 168 | { 169 | -1, 170 | (gchar *) "Release", 171 | NULL, 172 | NULL, 173 | NULL 174 | }, 175 | "handle-release", 176 | FALSE 177 | }; 178 | 179 | static const _ExtendedGDBusArgInfo _org_bluez_profile1_method_info_new_connection_IN_ARG_device = 180 | { 181 | { 182 | -1, 183 | (gchar *) "device", 184 | (gchar *) "o", 185 | NULL 186 | }, 187 | FALSE 188 | }; 189 | 190 | static const _ExtendedGDBusArgInfo _org_bluez_profile1_method_info_new_connection_IN_ARG_fd = 191 | { 192 | { 193 | -1, 194 | (gchar *) "fd", 195 | (gchar *) "h", 196 | NULL 197 | }, 198 | FALSE 199 | }; 200 | 201 | static const _ExtendedGDBusArgInfo _org_bluez_profile1_method_info_new_connection_IN_ARG_fd_properties = 202 | { 203 | { 204 | -1, 205 | (gchar *) "fd_properties", 206 | (gchar *) "a{sv}", 207 | NULL 208 | }, 209 | FALSE 210 | }; 211 | 212 | static const _ExtendedGDBusArgInfo * const _org_bluez_profile1_method_info_new_connection_IN_ARG_pointers[] = 213 | { 214 | &_org_bluez_profile1_method_info_new_connection_IN_ARG_device, 215 | &_org_bluez_profile1_method_info_new_connection_IN_ARG_fd, 216 | &_org_bluez_profile1_method_info_new_connection_IN_ARG_fd_properties, 217 | NULL 218 | }; 219 | 220 | static const _ExtendedGDBusMethodInfo _org_bluez_profile1_method_info_new_connection = 221 | { 222 | { 223 | -1, 224 | (gchar *) "NewConnection", 225 | (GDBusArgInfo **) &_org_bluez_profile1_method_info_new_connection_IN_ARG_pointers, 226 | NULL, 227 | NULL 228 | }, 229 | "handle-new-connection", 230 | FALSE 231 | }; 232 | 233 | static const _ExtendedGDBusArgInfo _org_bluez_profile1_method_info_request_disconnection_IN_ARG_device = 234 | { 235 | { 236 | -1, 237 | (gchar *) "device", 238 | (gchar *) "o", 239 | NULL 240 | }, 241 | FALSE 242 | }; 243 | 244 | static const _ExtendedGDBusArgInfo * const _org_bluez_profile1_method_info_request_disconnection_IN_ARG_pointers[] = 245 | { 246 | &_org_bluez_profile1_method_info_request_disconnection_IN_ARG_device, 247 | NULL 248 | }; 249 | 250 | static const _ExtendedGDBusMethodInfo _org_bluez_profile1_method_info_request_disconnection = 251 | { 252 | { 253 | -1, 254 | (gchar *) "RequestDisconnection", 255 | (GDBusArgInfo **) &_org_bluez_profile1_method_info_request_disconnection_IN_ARG_pointers, 256 | NULL, 257 | NULL 258 | }, 259 | "handle-request-disconnection", 260 | FALSE 261 | }; 262 | 263 | static const _ExtendedGDBusMethodInfo * const _org_bluez_profile1_method_info_pointers[] = 264 | { 265 | &_org_bluez_profile1_method_info_release, 266 | &_org_bluez_profile1_method_info_new_connection, 267 | &_org_bluez_profile1_method_info_request_disconnection, 268 | NULL 269 | }; 270 | 271 | static const _ExtendedGDBusInterfaceInfo _org_bluez_profile1_interface_info = 272 | { 273 | { 274 | -1, 275 | (gchar *) "org.bluez.Profile1", 276 | (GDBusMethodInfo **) &_org_bluez_profile1_method_info_pointers, 277 | NULL, 278 | NULL, 279 | NULL 280 | }, 281 | "org-bluez-profile1", 282 | }; 283 | 284 | 285 | /** 286 | * org_bluez_profile1_interface_info: 287 | * 288 | * Gets a machine-readable description of the org.bluez.Profile1 D-Bus interface. 289 | * 290 | * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free. 291 | */ 292 | GDBusInterfaceInfo * 293 | org_bluez_profile1_interface_info (void) 294 | { 295 | return (GDBusInterfaceInfo *) &_org_bluez_profile1_interface_info.parent_struct; 296 | } 297 | 298 | /** 299 | * org_bluez_profile1_override_properties: 300 | * @klass: The class structure for a #GObject-derived class. 301 | * @property_id_begin: The property id to assign to the first overridden property. 302 | * 303 | * Overrides all #GObject properties in the #OrgBluezProfile1 interface for a concrete class. 304 | * The properties are overridden in the order they are defined. 305 | * 306 | * Returns: The last property id. 307 | */ 308 | guint 309 | org_bluez_profile1_override_properties (GObjectClass *klass, guint property_id_begin) 310 | { 311 | return property_id_begin - 1; 312 | } 313 | 314 | 315 | 316 | /** 317 | * OrgBluezProfile1: 318 | * 319 | * Abstract interface type for the D-Bus interface org.bluez.Profile1. 320 | */ 321 | 322 | /** 323 | * OrgBluezProfile1Iface: 324 | * @parent_iface: The parent interface. 325 | * @handle_new_connection: Handler for the #OrgBluezProfile1::handle-new-connection signal. 326 | * @handle_release: Handler for the #OrgBluezProfile1::handle-release signal. 327 | * @handle_request_disconnection: Handler for the #OrgBluezProfile1::handle-request-disconnection signal. 328 | * 329 | * Virtual table for the D-Bus interface org.bluez.Profile1. 330 | */ 331 | 332 | typedef OrgBluezProfile1Iface OrgBluezProfile1Interface; 333 | G_DEFINE_INTERFACE (OrgBluezProfile1, org_bluez_profile1, G_TYPE_OBJECT); 334 | 335 | static void 336 | org_bluez_profile1_default_init (OrgBluezProfile1Iface *iface) 337 | { 338 | /* GObject signals for incoming D-Bus method calls: */ 339 | /** 340 | * OrgBluezProfile1::handle-release: 341 | * @object: A #OrgBluezProfile1. 342 | * @invocation: A #GDBusMethodInvocation. 343 | * 344 | * Signal emitted when a remote caller is invoking the Release() D-Bus method. 345 | * 346 | * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call org_bluez_profile1_complete_release() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned. 347 | * 348 | * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run. 349 | */ 350 | g_signal_new ("handle-release", 351 | G_TYPE_FROM_INTERFACE (iface), 352 | G_SIGNAL_RUN_LAST, 353 | G_STRUCT_OFFSET (OrgBluezProfile1Iface, handle_release), 354 | g_signal_accumulator_true_handled, 355 | NULL, 356 | g_cclosure_marshal_generic, 357 | G_TYPE_BOOLEAN, 358 | 1, 359 | G_TYPE_DBUS_METHOD_INVOCATION); 360 | 361 | /** 362 | * OrgBluezProfile1::handle-new-connection: 363 | * @object: A #OrgBluezProfile1. 364 | * @invocation: A #GDBusMethodInvocation. 365 | * @arg_device: Argument passed by remote caller. 366 | * @arg_fd: Argument passed by remote caller. 367 | * @arg_fd_properties: Argument passed by remote caller. 368 | * 369 | * Signal emitted when a remote caller is invoking the NewConnection() D-Bus method. 370 | * 371 | * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call org_bluez_profile1_complete_new_connection() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned. 372 | * 373 | * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run. 374 | */ 375 | g_signal_new ("handle-new-connection", 376 | G_TYPE_FROM_INTERFACE (iface), 377 | G_SIGNAL_RUN_LAST, 378 | G_STRUCT_OFFSET (OrgBluezProfile1Iface, handle_new_connection), 379 | g_signal_accumulator_true_handled, 380 | NULL, 381 | g_cclosure_marshal_generic, 382 | G_TYPE_BOOLEAN, 383 | 4, 384 | G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING, G_TYPE_VARIANT, G_TYPE_VARIANT); 385 | 386 | /** 387 | * OrgBluezProfile1::handle-request-disconnection: 388 | * @object: A #OrgBluezProfile1. 389 | * @invocation: A #GDBusMethodInvocation. 390 | * @arg_device: Argument passed by remote caller. 391 | * 392 | * Signal emitted when a remote caller is invoking the RequestDisconnection() D-Bus method. 393 | * 394 | * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call org_bluez_profile1_complete_request_disconnection() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned. 395 | * 396 | * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run. 397 | */ 398 | g_signal_new ("handle-request-disconnection", 399 | G_TYPE_FROM_INTERFACE (iface), 400 | G_SIGNAL_RUN_LAST, 401 | G_STRUCT_OFFSET (OrgBluezProfile1Iface, handle_request_disconnection), 402 | g_signal_accumulator_true_handled, 403 | NULL, 404 | g_cclosure_marshal_generic, 405 | G_TYPE_BOOLEAN, 406 | 2, 407 | G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING); 408 | 409 | } 410 | 411 | /** 412 | * org_bluez_profile1_call_release: 413 | * @proxy: A #OrgBluezProfile1Proxy. 414 | * @cancellable: (allow-none): A #GCancellable or %NULL. 415 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. 416 | * @user_data: User data to pass to @callback. 417 | * 418 | * Asynchronously invokes the Release() D-Bus method on @proxy. 419 | * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. 420 | * You can then call org_bluez_profile1_call_release_finish() to get the result of the operation. 421 | * 422 | * See org_bluez_profile1_call_release_sync() for the synchronous, blocking version of this method. 423 | */ 424 | void 425 | org_bluez_profile1_call_release ( 426 | OrgBluezProfile1 *proxy, 427 | GCancellable *cancellable, 428 | GAsyncReadyCallback callback, 429 | gpointer user_data) 430 | { 431 | g_dbus_proxy_call (G_DBUS_PROXY (proxy), 432 | "Release", 433 | g_variant_new ("()"), 434 | G_DBUS_CALL_FLAGS_NONE, 435 | -1, 436 | cancellable, 437 | callback, 438 | user_data); 439 | } 440 | 441 | /** 442 | * org_bluez_profile1_call_release_finish: 443 | * @proxy: A #OrgBluezProfile1Proxy. 444 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to org_bluez_profile1_call_release(). 445 | * @error: Return location for error or %NULL. 446 | * 447 | * Finishes an operation started with org_bluez_profile1_call_release(). 448 | * 449 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. 450 | */ 451 | gboolean 452 | org_bluez_profile1_call_release_finish ( 453 | OrgBluezProfile1 *proxy, 454 | GAsyncResult *res, 455 | GError **error) 456 | { 457 | GVariant *_ret; 458 | _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); 459 | if (_ret == NULL) 460 | goto _out; 461 | g_variant_get (_ret, 462 | "()"); 463 | g_variant_unref (_ret); 464 | _out: 465 | return _ret != NULL; 466 | } 467 | 468 | /** 469 | * org_bluez_profile1_call_release_sync: 470 | * @proxy: A #OrgBluezProfile1Proxy. 471 | * @cancellable: (allow-none): A #GCancellable or %NULL. 472 | * @error: Return location for error or %NULL. 473 | * 474 | * Synchronously invokes the Release() D-Bus method on @proxy. The calling thread is blocked until a reply is received. 475 | * 476 | * See org_bluez_profile1_call_release() for the asynchronous version of this method. 477 | * 478 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. 479 | */ 480 | gboolean 481 | org_bluez_profile1_call_release_sync ( 482 | OrgBluezProfile1 *proxy, 483 | GCancellable *cancellable, 484 | GError **error) 485 | { 486 | GVariant *_ret; 487 | _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), 488 | "Release", 489 | g_variant_new ("()"), 490 | G_DBUS_CALL_FLAGS_NONE, 491 | -1, 492 | cancellable, 493 | error); 494 | if (_ret == NULL) 495 | goto _out; 496 | g_variant_get (_ret, 497 | "()"); 498 | g_variant_unref (_ret); 499 | _out: 500 | return _ret != NULL; 501 | } 502 | 503 | /** 504 | * org_bluez_profile1_call_new_connection: 505 | * @proxy: A #OrgBluezProfile1Proxy. 506 | * @arg_device: Argument to pass with the method invocation. 507 | * @arg_fd: Argument to pass with the method invocation. 508 | * @arg_fd_properties: Argument to pass with the method invocation. 509 | * @cancellable: (allow-none): A #GCancellable or %NULL. 510 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. 511 | * @user_data: User data to pass to @callback. 512 | * 513 | * Asynchronously invokes the NewConnection() D-Bus method on @proxy. 514 | * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. 515 | * You can then call org_bluez_profile1_call_new_connection_finish() to get the result of the operation. 516 | * 517 | * See org_bluez_profile1_call_new_connection_sync() for the synchronous, blocking version of this method. 518 | */ 519 | void 520 | org_bluez_profile1_call_new_connection ( 521 | OrgBluezProfile1 *proxy, 522 | const gchar *arg_device, 523 | GVariant *arg_fd, 524 | GVariant *arg_fd_properties, 525 | GCancellable *cancellable, 526 | GAsyncReadyCallback callback, 527 | gpointer user_data) 528 | { 529 | g_dbus_proxy_call (G_DBUS_PROXY (proxy), 530 | "NewConnection", 531 | g_variant_new ("(o@h@a{sv})", 532 | arg_device, 533 | arg_fd, 534 | arg_fd_properties), 535 | G_DBUS_CALL_FLAGS_NONE, 536 | -1, 537 | cancellable, 538 | callback, 539 | user_data); 540 | } 541 | 542 | /** 543 | * org_bluez_profile1_call_new_connection_finish: 544 | * @proxy: A #OrgBluezProfile1Proxy. 545 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to org_bluez_profile1_call_new_connection(). 546 | * @error: Return location for error or %NULL. 547 | * 548 | * Finishes an operation started with org_bluez_profile1_call_new_connection(). 549 | * 550 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. 551 | */ 552 | gboolean 553 | org_bluez_profile1_call_new_connection_finish ( 554 | OrgBluezProfile1 *proxy, 555 | GAsyncResult *res, 556 | GError **error) 557 | { 558 | GVariant *_ret; 559 | _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); 560 | if (_ret == NULL) 561 | goto _out; 562 | g_variant_get (_ret, 563 | "()"); 564 | g_variant_unref (_ret); 565 | _out: 566 | return _ret != NULL; 567 | } 568 | 569 | /** 570 | * org_bluez_profile1_call_new_connection_sync: 571 | * @proxy: A #OrgBluezProfile1Proxy. 572 | * @arg_device: Argument to pass with the method invocation. 573 | * @arg_fd: Argument to pass with the method invocation. 574 | * @arg_fd_properties: Argument to pass with the method invocation. 575 | * @cancellable: (allow-none): A #GCancellable or %NULL. 576 | * @error: Return location for error or %NULL. 577 | * 578 | * Synchronously invokes the NewConnection() D-Bus method on @proxy. The calling thread is blocked until a reply is received. 579 | * 580 | * See org_bluez_profile1_call_new_connection() for the asynchronous version of this method. 581 | * 582 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. 583 | */ 584 | gboolean 585 | org_bluez_profile1_call_new_connection_sync ( 586 | OrgBluezProfile1 *proxy, 587 | const gchar *arg_device, 588 | GVariant *arg_fd, 589 | GVariant *arg_fd_properties, 590 | GCancellable *cancellable, 591 | GError **error) 592 | { 593 | GVariant *_ret; 594 | _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), 595 | "NewConnection", 596 | g_variant_new ("(o@h@a{sv})", 597 | arg_device, 598 | arg_fd, 599 | arg_fd_properties), 600 | G_DBUS_CALL_FLAGS_NONE, 601 | -1, 602 | cancellable, 603 | error); 604 | if (_ret == NULL) 605 | goto _out; 606 | g_variant_get (_ret, 607 | "()"); 608 | g_variant_unref (_ret); 609 | _out: 610 | return _ret != NULL; 611 | } 612 | 613 | /** 614 | * org_bluez_profile1_call_request_disconnection: 615 | * @proxy: A #OrgBluezProfile1Proxy. 616 | * @arg_device: Argument to pass with the method invocation. 617 | * @cancellable: (allow-none): A #GCancellable or %NULL. 618 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. 619 | * @user_data: User data to pass to @callback. 620 | * 621 | * Asynchronously invokes the RequestDisconnection() D-Bus method on @proxy. 622 | * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. 623 | * You can then call org_bluez_profile1_call_request_disconnection_finish() to get the result of the operation. 624 | * 625 | * See org_bluez_profile1_call_request_disconnection_sync() for the synchronous, blocking version of this method. 626 | */ 627 | void 628 | org_bluez_profile1_call_request_disconnection ( 629 | OrgBluezProfile1 *proxy, 630 | const gchar *arg_device, 631 | GCancellable *cancellable, 632 | GAsyncReadyCallback callback, 633 | gpointer user_data) 634 | { 635 | g_dbus_proxy_call (G_DBUS_PROXY (proxy), 636 | "RequestDisconnection", 637 | g_variant_new ("(o)", 638 | arg_device), 639 | G_DBUS_CALL_FLAGS_NONE, 640 | -1, 641 | cancellable, 642 | callback, 643 | user_data); 644 | } 645 | 646 | /** 647 | * org_bluez_profile1_call_request_disconnection_finish: 648 | * @proxy: A #OrgBluezProfile1Proxy. 649 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to org_bluez_profile1_call_request_disconnection(). 650 | * @error: Return location for error or %NULL. 651 | * 652 | * Finishes an operation started with org_bluez_profile1_call_request_disconnection(). 653 | * 654 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. 655 | */ 656 | gboolean 657 | org_bluez_profile1_call_request_disconnection_finish ( 658 | OrgBluezProfile1 *proxy, 659 | GAsyncResult *res, 660 | GError **error) 661 | { 662 | GVariant *_ret; 663 | _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); 664 | if (_ret == NULL) 665 | goto _out; 666 | g_variant_get (_ret, 667 | "()"); 668 | g_variant_unref (_ret); 669 | _out: 670 | return _ret != NULL; 671 | } 672 | 673 | /** 674 | * org_bluez_profile1_call_request_disconnection_sync: 675 | * @proxy: A #OrgBluezProfile1Proxy. 676 | * @arg_device: Argument to pass with the method invocation. 677 | * @cancellable: (allow-none): A #GCancellable or %NULL. 678 | * @error: Return location for error or %NULL. 679 | * 680 | * Synchronously invokes the RequestDisconnection() D-Bus method on @proxy. The calling thread is blocked until a reply is received. 681 | * 682 | * See org_bluez_profile1_call_request_disconnection() for the asynchronous version of this method. 683 | * 684 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. 685 | */ 686 | gboolean 687 | org_bluez_profile1_call_request_disconnection_sync ( 688 | OrgBluezProfile1 *proxy, 689 | const gchar *arg_device, 690 | GCancellable *cancellable, 691 | GError **error) 692 | { 693 | GVariant *_ret; 694 | _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), 695 | "RequestDisconnection", 696 | g_variant_new ("(o)", 697 | arg_device), 698 | G_DBUS_CALL_FLAGS_NONE, 699 | -1, 700 | cancellable, 701 | error); 702 | if (_ret == NULL) 703 | goto _out; 704 | g_variant_get (_ret, 705 | "()"); 706 | g_variant_unref (_ret); 707 | _out: 708 | return _ret != NULL; 709 | } 710 | 711 | /** 712 | * org_bluez_profile1_complete_release: 713 | * @object: A #OrgBluezProfile1. 714 | * @invocation: (transfer full): A #GDBusMethodInvocation. 715 | * 716 | * Helper function used in service implementations to finish handling invocations of the Release() D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar. 717 | * 718 | * This method will free @invocation, you cannot use it afterwards. 719 | */ 720 | void 721 | org_bluez_profile1_complete_release ( 722 | OrgBluezProfile1 *object, 723 | GDBusMethodInvocation *invocation) 724 | { 725 | g_dbus_method_invocation_return_value (invocation, 726 | g_variant_new ("()")); 727 | } 728 | 729 | /** 730 | * org_bluez_profile1_complete_new_connection: 731 | * @object: A #OrgBluezProfile1. 732 | * @invocation: (transfer full): A #GDBusMethodInvocation. 733 | * 734 | * Helper function used in service implementations to finish handling invocations of the NewConnection() D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar. 735 | * 736 | * This method will free @invocation, you cannot use it afterwards. 737 | */ 738 | void 739 | org_bluez_profile1_complete_new_connection ( 740 | OrgBluezProfile1 *object, 741 | GDBusMethodInvocation *invocation) 742 | { 743 | g_dbus_method_invocation_return_value (invocation, 744 | g_variant_new ("()")); 745 | } 746 | 747 | /** 748 | * org_bluez_profile1_complete_request_disconnection: 749 | * @object: A #OrgBluezProfile1. 750 | * @invocation: (transfer full): A #GDBusMethodInvocation. 751 | * 752 | * Helper function used in service implementations to finish handling invocations of the RequestDisconnection() D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar. 753 | * 754 | * This method will free @invocation, you cannot use it afterwards. 755 | */ 756 | void 757 | org_bluez_profile1_complete_request_disconnection ( 758 | OrgBluezProfile1 *object, 759 | GDBusMethodInvocation *invocation) 760 | { 761 | g_dbus_method_invocation_return_value (invocation, 762 | g_variant_new ("()")); 763 | } 764 | 765 | /* ------------------------------------------------------------------------ */ 766 | 767 | /** 768 | * OrgBluezProfile1Proxy: 769 | * 770 | * The #OrgBluezProfile1Proxy structure contains only private data and should only be accessed using the provided API. 771 | */ 772 | 773 | /** 774 | * OrgBluezProfile1ProxyClass: 775 | * @parent_class: The parent class. 776 | * 777 | * Class structure for #OrgBluezProfile1Proxy. 778 | */ 779 | 780 | struct _OrgBluezProfile1ProxyPrivate 781 | { 782 | GData *qdata; 783 | }; 784 | 785 | static void org_bluez_profile1_proxy_iface_init (OrgBluezProfile1Iface *iface); 786 | 787 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 788 | G_DEFINE_TYPE_WITH_CODE (OrgBluezProfile1Proxy, org_bluez_profile1_proxy, G_TYPE_DBUS_PROXY, 789 | G_ADD_PRIVATE (OrgBluezProfile1Proxy) 790 | G_IMPLEMENT_INTERFACE (TYPE_ORG_BLUEZ_PROFILE1, org_bluez_profile1_proxy_iface_init)); 791 | 792 | #else 793 | G_DEFINE_TYPE_WITH_CODE (OrgBluezProfile1Proxy, org_bluez_profile1_proxy, G_TYPE_DBUS_PROXY, 794 | G_IMPLEMENT_INTERFACE (TYPE_ORG_BLUEZ_PROFILE1, org_bluez_profile1_proxy_iface_init)); 795 | 796 | #endif 797 | static void 798 | org_bluez_profile1_proxy_finalize (GObject *object) 799 | { 800 | OrgBluezProfile1Proxy *proxy = ORG_BLUEZ_PROFILE1_PROXY (object); 801 | g_datalist_clear (&proxy->priv->qdata); 802 | G_OBJECT_CLASS (org_bluez_profile1_proxy_parent_class)->finalize (object); 803 | } 804 | 805 | static void 806 | org_bluez_profile1_proxy_get_property (GObject *object, 807 | guint prop_id, 808 | GValue *value, 809 | GParamSpec *pspec G_GNUC_UNUSED) 810 | { 811 | } 812 | 813 | static void 814 | org_bluez_profile1_proxy_set_property (GObject *object, 815 | guint prop_id, 816 | const GValue *value, 817 | GParamSpec *pspec G_GNUC_UNUSED) 818 | { 819 | } 820 | 821 | static void 822 | org_bluez_profile1_proxy_g_signal (GDBusProxy *proxy, 823 | const gchar *sender_name G_GNUC_UNUSED, 824 | const gchar *signal_name, 825 | GVariant *parameters) 826 | { 827 | _ExtendedGDBusSignalInfo *info; 828 | GVariantIter iter; 829 | GVariant *child; 830 | GValue *paramv; 831 | guint num_params; 832 | guint n; 833 | guint signal_id; 834 | info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_org_bluez_profile1_interface_info.parent_struct, signal_name); 835 | if (info == NULL) 836 | return; 837 | num_params = g_variant_n_children (parameters); 838 | paramv = g_new0 (GValue, num_params + 1); 839 | g_value_init (¶mv[0], TYPE_ORG_BLUEZ_PROFILE1); 840 | g_value_set_object (¶mv[0], proxy); 841 | g_variant_iter_init (&iter, parameters); 842 | n = 1; 843 | while ((child = g_variant_iter_next_value (&iter)) != NULL) 844 | { 845 | _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1]; 846 | if (arg_info->use_gvariant) 847 | { 848 | g_value_init (¶mv[n], G_TYPE_VARIANT); 849 | g_value_set_variant (¶mv[n], child); 850 | n++; 851 | } 852 | else 853 | g_dbus_gvariant_to_gvalue (child, ¶mv[n++]); 854 | g_variant_unref (child); 855 | } 856 | signal_id = g_signal_lookup (info->signal_name, TYPE_ORG_BLUEZ_PROFILE1); 857 | g_signal_emitv (paramv, signal_id, 0, NULL); 858 | for (n = 0; n < num_params + 1; n++) 859 | g_value_unset (¶mv[n]); 860 | g_free (paramv); 861 | } 862 | 863 | static void 864 | org_bluez_profile1_proxy_g_properties_changed (GDBusProxy *_proxy, 865 | GVariant *changed_properties, 866 | const gchar *const *invalidated_properties) 867 | { 868 | OrgBluezProfile1Proxy *proxy = ORG_BLUEZ_PROFILE1_PROXY (_proxy); 869 | guint n; 870 | const gchar *key; 871 | GVariantIter *iter; 872 | _ExtendedGDBusPropertyInfo *info; 873 | g_variant_get (changed_properties, "a{sv}", &iter); 874 | while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) 875 | { 876 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_org_bluez_profile1_interface_info.parent_struct, key); 877 | g_datalist_remove_data (&proxy->priv->qdata, key); 878 | if (info != NULL) 879 | g_object_notify (G_OBJECT (proxy), info->hyphen_name); 880 | } 881 | g_variant_iter_free (iter); 882 | for (n = 0; invalidated_properties[n] != NULL; n++) 883 | { 884 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_org_bluez_profile1_interface_info.parent_struct, invalidated_properties[n]); 885 | g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]); 886 | if (info != NULL) 887 | g_object_notify (G_OBJECT (proxy), info->hyphen_name); 888 | } 889 | } 890 | 891 | static void 892 | org_bluez_profile1_proxy_init (OrgBluezProfile1Proxy *proxy) 893 | { 894 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 895 | proxy->priv = org_bluez_profile1_proxy_get_instance_private (proxy); 896 | #else 897 | proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_ORG_BLUEZ_PROFILE1_PROXY, OrgBluezProfile1ProxyPrivate); 898 | #endif 899 | 900 | g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), org_bluez_profile1_interface_info ()); 901 | } 902 | 903 | static void 904 | org_bluez_profile1_proxy_class_init (OrgBluezProfile1ProxyClass *klass) 905 | { 906 | GObjectClass *gobject_class; 907 | GDBusProxyClass *proxy_class; 908 | 909 | gobject_class = G_OBJECT_CLASS (klass); 910 | gobject_class->finalize = org_bluez_profile1_proxy_finalize; 911 | gobject_class->get_property = org_bluez_profile1_proxy_get_property; 912 | gobject_class->set_property = org_bluez_profile1_proxy_set_property; 913 | 914 | proxy_class = G_DBUS_PROXY_CLASS (klass); 915 | proxy_class->g_signal = org_bluez_profile1_proxy_g_signal; 916 | proxy_class->g_properties_changed = org_bluez_profile1_proxy_g_properties_changed; 917 | 918 | #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 919 | g_type_class_add_private (klass, sizeof (OrgBluezProfile1ProxyPrivate)); 920 | #endif 921 | } 922 | 923 | static void 924 | org_bluez_profile1_proxy_iface_init (OrgBluezProfile1Iface *iface) 925 | { 926 | } 927 | 928 | /** 929 | * org_bluez_profile1_proxy_new: 930 | * @connection: A #GDBusConnection. 931 | * @flags: Flags from the #GDBusProxyFlags enumeration. 932 | * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. 933 | * @object_path: An object path. 934 | * @cancellable: (allow-none): A #GCancellable or %NULL. 935 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied. 936 | * @user_data: User data to pass to @callback. 937 | * 938 | * Asynchronously creates a proxy for the D-Bus interface org.bluez.Profile1. See g_dbus_proxy_new() for more details. 939 | * 940 | * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. 941 | * You can then call org_bluez_profile1_proxy_new_finish() to get the result of the operation. 942 | * 943 | * See org_bluez_profile1_proxy_new_sync() for the synchronous, blocking version of this constructor. 944 | */ 945 | void 946 | org_bluez_profile1_proxy_new ( 947 | GDBusConnection *connection, 948 | GDBusProxyFlags flags, 949 | const gchar *name, 950 | const gchar *object_path, 951 | GCancellable *cancellable, 952 | GAsyncReadyCallback callback, 953 | gpointer user_data) 954 | { 955 | g_async_initable_new_async (TYPE_ORG_BLUEZ_PROFILE1_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.bluez.Profile1", NULL); 956 | } 957 | 958 | /** 959 | * org_bluez_profile1_proxy_new_finish: 960 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to org_bluez_profile1_proxy_new(). 961 | * @error: Return location for error or %NULL 962 | * 963 | * Finishes an operation started with org_bluez_profile1_proxy_new(). 964 | * 965 | * Returns: (transfer full) (type OrgBluezProfile1Proxy): The constructed proxy object or %NULL if @error is set. 966 | */ 967 | OrgBluezProfile1 * 968 | org_bluez_profile1_proxy_new_finish ( 969 | GAsyncResult *res, 970 | GError **error) 971 | { 972 | GObject *ret; 973 | GObject *source_object; 974 | source_object = g_async_result_get_source_object (res); 975 | ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); 976 | g_object_unref (source_object); 977 | if (ret != NULL) 978 | return ORG_BLUEZ_PROFILE1 (ret); 979 | else 980 | return NULL; 981 | } 982 | 983 | /** 984 | * org_bluez_profile1_proxy_new_sync: 985 | * @connection: A #GDBusConnection. 986 | * @flags: Flags from the #GDBusProxyFlags enumeration. 987 | * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. 988 | * @object_path: An object path. 989 | * @cancellable: (allow-none): A #GCancellable or %NULL. 990 | * @error: Return location for error or %NULL 991 | * 992 | * Synchronously creates a proxy for the D-Bus interface org.bluez.Profile1. See g_dbus_proxy_new_sync() for more details. 993 | * 994 | * The calling thread is blocked until a reply is received. 995 | * 996 | * See org_bluez_profile1_proxy_new() for the asynchronous version of this constructor. 997 | * 998 | * Returns: (transfer full) (type OrgBluezProfile1Proxy): The constructed proxy object or %NULL if @error is set. 999 | */ 1000 | OrgBluezProfile1 * 1001 | org_bluez_profile1_proxy_new_sync ( 1002 | GDBusConnection *connection, 1003 | GDBusProxyFlags flags, 1004 | const gchar *name, 1005 | const gchar *object_path, 1006 | GCancellable *cancellable, 1007 | GError **error) 1008 | { 1009 | GInitable *ret; 1010 | ret = g_initable_new (TYPE_ORG_BLUEZ_PROFILE1_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.bluez.Profile1", NULL); 1011 | if (ret != NULL) 1012 | return ORG_BLUEZ_PROFILE1 (ret); 1013 | else 1014 | return NULL; 1015 | } 1016 | 1017 | 1018 | /** 1019 | * org_bluez_profile1_proxy_new_for_bus: 1020 | * @bus_type: A #GBusType. 1021 | * @flags: Flags from the #GDBusProxyFlags enumeration. 1022 | * @name: A bus name (well-known or unique). 1023 | * @object_path: An object path. 1024 | * @cancellable: (allow-none): A #GCancellable or %NULL. 1025 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied. 1026 | * @user_data: User data to pass to @callback. 1027 | * 1028 | * Like org_bluez_profile1_proxy_new() but takes a #GBusType instead of a #GDBusConnection. 1029 | * 1030 | * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. 1031 | * You can then call org_bluez_profile1_proxy_new_for_bus_finish() to get the result of the operation. 1032 | * 1033 | * See org_bluez_profile1_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor. 1034 | */ 1035 | void 1036 | org_bluez_profile1_proxy_new_for_bus ( 1037 | GBusType bus_type, 1038 | GDBusProxyFlags flags, 1039 | const gchar *name, 1040 | const gchar *object_path, 1041 | GCancellable *cancellable, 1042 | GAsyncReadyCallback callback, 1043 | gpointer user_data) 1044 | { 1045 | g_async_initable_new_async (TYPE_ORG_BLUEZ_PROFILE1_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.bluez.Profile1", NULL); 1046 | } 1047 | 1048 | /** 1049 | * org_bluez_profile1_proxy_new_for_bus_finish: 1050 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to org_bluez_profile1_proxy_new_for_bus(). 1051 | * @error: Return location for error or %NULL 1052 | * 1053 | * Finishes an operation started with org_bluez_profile1_proxy_new_for_bus(). 1054 | * 1055 | * Returns: (transfer full) (type OrgBluezProfile1Proxy): The constructed proxy object or %NULL if @error is set. 1056 | */ 1057 | OrgBluezProfile1 * 1058 | org_bluez_profile1_proxy_new_for_bus_finish ( 1059 | GAsyncResult *res, 1060 | GError **error) 1061 | { 1062 | GObject *ret; 1063 | GObject *source_object; 1064 | source_object = g_async_result_get_source_object (res); 1065 | ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); 1066 | g_object_unref (source_object); 1067 | if (ret != NULL) 1068 | return ORG_BLUEZ_PROFILE1 (ret); 1069 | else 1070 | return NULL; 1071 | } 1072 | 1073 | /** 1074 | * org_bluez_profile1_proxy_new_for_bus_sync: 1075 | * @bus_type: A #GBusType. 1076 | * @flags: Flags from the #GDBusProxyFlags enumeration. 1077 | * @name: A bus name (well-known or unique). 1078 | * @object_path: An object path. 1079 | * @cancellable: (allow-none): A #GCancellable or %NULL. 1080 | * @error: Return location for error or %NULL 1081 | * 1082 | * Like org_bluez_profile1_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection. 1083 | * 1084 | * The calling thread is blocked until a reply is received. 1085 | * 1086 | * See org_bluez_profile1_proxy_new_for_bus() for the asynchronous version of this constructor. 1087 | * 1088 | * Returns: (transfer full) (type OrgBluezProfile1Proxy): The constructed proxy object or %NULL if @error is set. 1089 | */ 1090 | OrgBluezProfile1 * 1091 | org_bluez_profile1_proxy_new_for_bus_sync ( 1092 | GBusType bus_type, 1093 | GDBusProxyFlags flags, 1094 | const gchar *name, 1095 | const gchar *object_path, 1096 | GCancellable *cancellable, 1097 | GError **error) 1098 | { 1099 | GInitable *ret; 1100 | ret = g_initable_new (TYPE_ORG_BLUEZ_PROFILE1_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.bluez.Profile1", NULL); 1101 | if (ret != NULL) 1102 | return ORG_BLUEZ_PROFILE1 (ret); 1103 | else 1104 | return NULL; 1105 | } 1106 | 1107 | 1108 | /* ------------------------------------------------------------------------ */ 1109 | 1110 | /** 1111 | * OrgBluezProfile1Skeleton: 1112 | * 1113 | * The #OrgBluezProfile1Skeleton structure contains only private data and should only be accessed using the provided API. 1114 | */ 1115 | 1116 | /** 1117 | * OrgBluezProfile1SkeletonClass: 1118 | * @parent_class: The parent class. 1119 | * 1120 | * Class structure for #OrgBluezProfile1Skeleton. 1121 | */ 1122 | 1123 | struct _OrgBluezProfile1SkeletonPrivate 1124 | { 1125 | GValue *properties; 1126 | GList *changed_properties; 1127 | GSource *changed_properties_idle_source; 1128 | GMainContext *context; 1129 | GMutex lock; 1130 | }; 1131 | 1132 | static void 1133 | _org_bluez_profile1_skeleton_handle_method_call ( 1134 | GDBusConnection *connection G_GNUC_UNUSED, 1135 | const gchar *sender G_GNUC_UNUSED, 1136 | const gchar *object_path G_GNUC_UNUSED, 1137 | const gchar *interface_name, 1138 | const gchar *method_name, 1139 | GVariant *parameters, 1140 | GDBusMethodInvocation *invocation, 1141 | gpointer user_data) 1142 | { 1143 | OrgBluezProfile1Skeleton *skeleton = ORG_BLUEZ_PROFILE1_SKELETON (user_data); 1144 | _ExtendedGDBusMethodInfo *info; 1145 | GVariantIter iter; 1146 | GVariant *child; 1147 | GValue *paramv; 1148 | guint num_params; 1149 | guint num_extra; 1150 | guint n; 1151 | guint signal_id; 1152 | GValue return_value = G_VALUE_INIT; 1153 | info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation); 1154 | g_assert (info != NULL); 1155 | num_params = g_variant_n_children (parameters); 1156 | num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra); 1157 | n = 0; 1158 | g_value_init (¶mv[n], TYPE_ORG_BLUEZ_PROFILE1); 1159 | g_value_set_object (¶mv[n++], skeleton); 1160 | g_value_init (¶mv[n], G_TYPE_DBUS_METHOD_INVOCATION); 1161 | g_value_set_object (¶mv[n++], invocation); 1162 | if (info->pass_fdlist) 1163 | { 1164 | #ifdef G_OS_UNIX 1165 | g_value_init (¶mv[n], G_TYPE_UNIX_FD_LIST); 1166 | g_value_set_object (¶mv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation))); 1167 | #else 1168 | g_assert_not_reached (); 1169 | #endif 1170 | } 1171 | g_variant_iter_init (&iter, parameters); 1172 | while ((child = g_variant_iter_next_value (&iter)) != NULL) 1173 | { 1174 | _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra]; 1175 | if (arg_info->use_gvariant) 1176 | { 1177 | g_value_init (¶mv[n], G_TYPE_VARIANT); 1178 | g_value_set_variant (¶mv[n], child); 1179 | n++; 1180 | } 1181 | else 1182 | g_dbus_gvariant_to_gvalue (child, ¶mv[n++]); 1183 | g_variant_unref (child); 1184 | } 1185 | signal_id = g_signal_lookup (info->signal_name, TYPE_ORG_BLUEZ_PROFILE1); 1186 | g_value_init (&return_value, G_TYPE_BOOLEAN); 1187 | g_signal_emitv (paramv, signal_id, 0, &return_value); 1188 | if (!g_value_get_boolean (&return_value)) 1189 | g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name); 1190 | g_value_unset (&return_value); 1191 | for (n = 0; n < num_params + num_extra; n++) 1192 | g_value_unset (¶mv[n]); 1193 | g_free (paramv); 1194 | } 1195 | 1196 | static GVariant * 1197 | _org_bluez_profile1_skeleton_handle_get_property ( 1198 | GDBusConnection *connection G_GNUC_UNUSED, 1199 | const gchar *sender G_GNUC_UNUSED, 1200 | const gchar *object_path G_GNUC_UNUSED, 1201 | const gchar *interface_name G_GNUC_UNUSED, 1202 | const gchar *property_name, 1203 | GError **error, 1204 | gpointer user_data) 1205 | { 1206 | OrgBluezProfile1Skeleton *skeleton = ORG_BLUEZ_PROFILE1_SKELETON (user_data); 1207 | GValue value = G_VALUE_INIT; 1208 | GParamSpec *pspec; 1209 | _ExtendedGDBusPropertyInfo *info; 1210 | GVariant *ret; 1211 | ret = NULL; 1212 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_org_bluez_profile1_interface_info.parent_struct, property_name); 1213 | g_assert (info != NULL); 1214 | pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); 1215 | if (pspec == NULL) 1216 | { 1217 | g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name); 1218 | } 1219 | else 1220 | { 1221 | g_value_init (&value, pspec->value_type); 1222 | g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value); 1223 | ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature)); 1224 | g_value_unset (&value); 1225 | } 1226 | return ret; 1227 | } 1228 | 1229 | static gboolean 1230 | _org_bluez_profile1_skeleton_handle_set_property ( 1231 | GDBusConnection *connection G_GNUC_UNUSED, 1232 | const gchar *sender G_GNUC_UNUSED, 1233 | const gchar *object_path G_GNUC_UNUSED, 1234 | const gchar *interface_name G_GNUC_UNUSED, 1235 | const gchar *property_name, 1236 | GVariant *variant, 1237 | GError **error, 1238 | gpointer user_data) 1239 | { 1240 | OrgBluezProfile1Skeleton *skeleton = ORG_BLUEZ_PROFILE1_SKELETON (user_data); 1241 | GValue value = G_VALUE_INIT; 1242 | GParamSpec *pspec; 1243 | _ExtendedGDBusPropertyInfo *info; 1244 | gboolean ret; 1245 | ret = FALSE; 1246 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_org_bluez_profile1_interface_info.parent_struct, property_name); 1247 | g_assert (info != NULL); 1248 | pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); 1249 | if (pspec == NULL) 1250 | { 1251 | g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name); 1252 | } 1253 | else 1254 | { 1255 | if (info->use_gvariant) 1256 | g_value_set_variant (&value, variant); 1257 | else 1258 | g_dbus_gvariant_to_gvalue (variant, &value); 1259 | g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value); 1260 | g_value_unset (&value); 1261 | ret = TRUE; 1262 | } 1263 | return ret; 1264 | } 1265 | 1266 | static const GDBusInterfaceVTable _org_bluez_profile1_skeleton_vtable = 1267 | { 1268 | _org_bluez_profile1_skeleton_handle_method_call, 1269 | _org_bluez_profile1_skeleton_handle_get_property, 1270 | _org_bluez_profile1_skeleton_handle_set_property, 1271 | {NULL} 1272 | }; 1273 | 1274 | static GDBusInterfaceInfo * 1275 | org_bluez_profile1_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED) 1276 | { 1277 | return org_bluez_profile1_interface_info (); 1278 | } 1279 | 1280 | static GDBusInterfaceVTable * 1281 | org_bluez_profile1_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED) 1282 | { 1283 | return (GDBusInterfaceVTable *) &_org_bluez_profile1_skeleton_vtable; 1284 | } 1285 | 1286 | static GVariant * 1287 | org_bluez_profile1_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton) 1288 | { 1289 | OrgBluezProfile1Skeleton *skeleton = ORG_BLUEZ_PROFILE1_SKELETON (_skeleton); 1290 | 1291 | GVariantBuilder builder; 1292 | guint n; 1293 | g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); 1294 | if (_org_bluez_profile1_interface_info.parent_struct.properties == NULL) 1295 | goto out; 1296 | for (n = 0; _org_bluez_profile1_interface_info.parent_struct.properties[n] != NULL; n++) 1297 | { 1298 | GDBusPropertyInfo *info = _org_bluez_profile1_interface_info.parent_struct.properties[n]; 1299 | if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE) 1300 | { 1301 | GVariant *value; 1302 | value = _org_bluez_profile1_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.bluez.Profile1", info->name, NULL, skeleton); 1303 | if (value != NULL) 1304 | { 1305 | g_variant_take_ref (value); 1306 | g_variant_builder_add (&builder, "{sv}", info->name, value); 1307 | g_variant_unref (value); 1308 | } 1309 | } 1310 | } 1311 | out: 1312 | return g_variant_builder_end (&builder); 1313 | } 1314 | 1315 | static void 1316 | org_bluez_profile1_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton) 1317 | { 1318 | } 1319 | 1320 | static void org_bluez_profile1_skeleton_iface_init (OrgBluezProfile1Iface *iface); 1321 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 1322 | G_DEFINE_TYPE_WITH_CODE (OrgBluezProfile1Skeleton, org_bluez_profile1_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, 1323 | G_ADD_PRIVATE (OrgBluezProfile1Skeleton) 1324 | G_IMPLEMENT_INTERFACE (TYPE_ORG_BLUEZ_PROFILE1, org_bluez_profile1_skeleton_iface_init)); 1325 | 1326 | #else 1327 | G_DEFINE_TYPE_WITH_CODE (OrgBluezProfile1Skeleton, org_bluez_profile1_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, 1328 | G_IMPLEMENT_INTERFACE (TYPE_ORG_BLUEZ_PROFILE1, org_bluez_profile1_skeleton_iface_init)); 1329 | 1330 | #endif 1331 | static void 1332 | org_bluez_profile1_skeleton_finalize (GObject *object) 1333 | { 1334 | OrgBluezProfile1Skeleton *skeleton = ORG_BLUEZ_PROFILE1_SKELETON (object); 1335 | g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free); 1336 | if (skeleton->priv->changed_properties_idle_source != NULL) 1337 | g_source_destroy (skeleton->priv->changed_properties_idle_source); 1338 | g_main_context_unref (skeleton->priv->context); 1339 | g_mutex_clear (&skeleton->priv->lock); 1340 | G_OBJECT_CLASS (org_bluez_profile1_skeleton_parent_class)->finalize (object); 1341 | } 1342 | 1343 | static void 1344 | org_bluez_profile1_skeleton_init (OrgBluezProfile1Skeleton *skeleton) 1345 | { 1346 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 1347 | skeleton->priv = org_bluez_profile1_skeleton_get_instance_private (skeleton); 1348 | #else 1349 | skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_ORG_BLUEZ_PROFILE1_SKELETON, OrgBluezProfile1SkeletonPrivate); 1350 | #endif 1351 | 1352 | g_mutex_init (&skeleton->priv->lock); 1353 | skeleton->priv->context = g_main_context_ref_thread_default (); 1354 | } 1355 | 1356 | static void 1357 | org_bluez_profile1_skeleton_class_init (OrgBluezProfile1SkeletonClass *klass) 1358 | { 1359 | GObjectClass *gobject_class; 1360 | GDBusInterfaceSkeletonClass *skeleton_class; 1361 | 1362 | gobject_class = G_OBJECT_CLASS (klass); 1363 | gobject_class->finalize = org_bluez_profile1_skeleton_finalize; 1364 | 1365 | skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass); 1366 | skeleton_class->get_info = org_bluez_profile1_skeleton_dbus_interface_get_info; 1367 | skeleton_class->get_properties = org_bluez_profile1_skeleton_dbus_interface_get_properties; 1368 | skeleton_class->flush = org_bluez_profile1_skeleton_dbus_interface_flush; 1369 | skeleton_class->get_vtable = org_bluez_profile1_skeleton_dbus_interface_get_vtable; 1370 | 1371 | #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 1372 | g_type_class_add_private (klass, sizeof (OrgBluezProfile1SkeletonPrivate)); 1373 | #endif 1374 | } 1375 | 1376 | static void 1377 | org_bluez_profile1_skeleton_iface_init (OrgBluezProfile1Iface *iface) 1378 | { 1379 | } 1380 | 1381 | /** 1382 | * org_bluez_profile1_skeleton_new: 1383 | * 1384 | * Creates a skeleton object for the D-Bus interface org.bluez.Profile1. 1385 | * 1386 | * Returns: (transfer full) (type OrgBluezProfile1Skeleton): The skeleton object. 1387 | */ 1388 | OrgBluezProfile1 * 1389 | org_bluez_profile1_skeleton_new (void) 1390 | { 1391 | return ORG_BLUEZ_PROFILE1 (g_object_new (TYPE_ORG_BLUEZ_PROFILE1_SKELETON, NULL)); 1392 | } 1393 | 1394 | -------------------------------------------------------------------------------- /profile1-iface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by gdbus-codegen 2.48.2. DO NOT EDIT. 3 | * 4 | * The license of this code is the same as for the source it was derived from. 5 | */ 6 | 7 | #ifndef __PROFILE1_IFACE_H__ 8 | #define __PROFILE1_IFACE_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | 15 | /* ------------------------------------------------------------------------ */ 16 | /* Declarations for org.bluez.Profile1 */ 17 | 18 | #define TYPE_ORG_BLUEZ_PROFILE1 (org_bluez_profile1_get_type ()) 19 | #define ORG_BLUEZ_PROFILE1(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_ORG_BLUEZ_PROFILE1, OrgBluezProfile1)) 20 | #define IS_ORG_BLUEZ_PROFILE1(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_ORG_BLUEZ_PROFILE1)) 21 | #define ORG_BLUEZ_PROFILE1_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), TYPE_ORG_BLUEZ_PROFILE1, OrgBluezProfile1Iface)) 22 | 23 | struct _OrgBluezProfile1; 24 | typedef struct _OrgBluezProfile1 OrgBluezProfile1; 25 | typedef struct _OrgBluezProfile1Iface OrgBluezProfile1Iface; 26 | 27 | struct _OrgBluezProfile1Iface 28 | { 29 | GTypeInterface parent_iface; 30 | 31 | gboolean (*handle_new_connection) ( 32 | OrgBluezProfile1 *object, 33 | GDBusMethodInvocation *invocation, 34 | const gchar *arg_device, 35 | GVariant *arg_fd, 36 | GVariant *arg_fd_properties); 37 | 38 | gboolean (*handle_release) ( 39 | OrgBluezProfile1 *object, 40 | GDBusMethodInvocation *invocation); 41 | 42 | gboolean (*handle_request_disconnection) ( 43 | OrgBluezProfile1 *object, 44 | GDBusMethodInvocation *invocation, 45 | const gchar *arg_device); 46 | 47 | }; 48 | 49 | GType org_bluez_profile1_get_type (void) G_GNUC_CONST; 50 | 51 | GDBusInterfaceInfo *org_bluez_profile1_interface_info (void); 52 | guint org_bluez_profile1_override_properties (GObjectClass *klass, guint property_id_begin); 53 | 54 | 55 | /* D-Bus method call completion functions: */ 56 | void org_bluez_profile1_complete_release ( 57 | OrgBluezProfile1 *object, 58 | GDBusMethodInvocation *invocation); 59 | 60 | void org_bluez_profile1_complete_new_connection ( 61 | OrgBluezProfile1 *object, 62 | GDBusMethodInvocation *invocation); 63 | 64 | void org_bluez_profile1_complete_request_disconnection ( 65 | OrgBluezProfile1 *object, 66 | GDBusMethodInvocation *invocation); 67 | 68 | 69 | 70 | /* D-Bus method calls: */ 71 | void org_bluez_profile1_call_release ( 72 | OrgBluezProfile1 *proxy, 73 | GCancellable *cancellable, 74 | GAsyncReadyCallback callback, 75 | gpointer user_data); 76 | 77 | gboolean org_bluez_profile1_call_release_finish ( 78 | OrgBluezProfile1 *proxy, 79 | GAsyncResult *res, 80 | GError **error); 81 | 82 | gboolean org_bluez_profile1_call_release_sync ( 83 | OrgBluezProfile1 *proxy, 84 | GCancellable *cancellable, 85 | GError **error); 86 | 87 | void org_bluez_profile1_call_new_connection ( 88 | OrgBluezProfile1 *proxy, 89 | const gchar *arg_device, 90 | GVariant *arg_fd, 91 | GVariant *arg_fd_properties, 92 | GCancellable *cancellable, 93 | GAsyncReadyCallback callback, 94 | gpointer user_data); 95 | 96 | gboolean org_bluez_profile1_call_new_connection_finish ( 97 | OrgBluezProfile1 *proxy, 98 | GAsyncResult *res, 99 | GError **error); 100 | 101 | gboolean org_bluez_profile1_call_new_connection_sync ( 102 | OrgBluezProfile1 *proxy, 103 | const gchar *arg_device, 104 | GVariant *arg_fd, 105 | GVariant *arg_fd_properties, 106 | GCancellable *cancellable, 107 | GError **error); 108 | 109 | void org_bluez_profile1_call_request_disconnection ( 110 | OrgBluezProfile1 *proxy, 111 | const gchar *arg_device, 112 | GCancellable *cancellable, 113 | GAsyncReadyCallback callback, 114 | gpointer user_data); 115 | 116 | gboolean org_bluez_profile1_call_request_disconnection_finish ( 117 | OrgBluezProfile1 *proxy, 118 | GAsyncResult *res, 119 | GError **error); 120 | 121 | gboolean org_bluez_profile1_call_request_disconnection_sync ( 122 | OrgBluezProfile1 *proxy, 123 | const gchar *arg_device, 124 | GCancellable *cancellable, 125 | GError **error); 126 | 127 | 128 | 129 | /* ---- */ 130 | 131 | #define TYPE_ORG_BLUEZ_PROFILE1_PROXY (org_bluez_profile1_proxy_get_type ()) 132 | #define ORG_BLUEZ_PROFILE1_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_ORG_BLUEZ_PROFILE1_PROXY, OrgBluezProfile1Proxy)) 133 | #define ORG_BLUEZ_PROFILE1_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_ORG_BLUEZ_PROFILE1_PROXY, OrgBluezProfile1ProxyClass)) 134 | #define ORG_BLUEZ_PROFILE1_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_ORG_BLUEZ_PROFILE1_PROXY, OrgBluezProfile1ProxyClass)) 135 | #define IS_ORG_BLUEZ_PROFILE1_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_ORG_BLUEZ_PROFILE1_PROXY)) 136 | #define IS_ORG_BLUEZ_PROFILE1_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_ORG_BLUEZ_PROFILE1_PROXY)) 137 | 138 | typedef struct _OrgBluezProfile1Proxy OrgBluezProfile1Proxy; 139 | typedef struct _OrgBluezProfile1ProxyClass OrgBluezProfile1ProxyClass; 140 | typedef struct _OrgBluezProfile1ProxyPrivate OrgBluezProfile1ProxyPrivate; 141 | 142 | struct _OrgBluezProfile1Proxy 143 | { 144 | /*< private >*/ 145 | GDBusProxy parent_instance; 146 | OrgBluezProfile1ProxyPrivate *priv; 147 | }; 148 | 149 | struct _OrgBluezProfile1ProxyClass 150 | { 151 | GDBusProxyClass parent_class; 152 | }; 153 | 154 | GType org_bluez_profile1_proxy_get_type (void) G_GNUC_CONST; 155 | 156 | #if GLIB_CHECK_VERSION(2, 44, 0) 157 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (OrgBluezProfile1Proxy, g_object_unref) 158 | #endif 159 | 160 | void org_bluez_profile1_proxy_new ( 161 | GDBusConnection *connection, 162 | GDBusProxyFlags flags, 163 | const gchar *name, 164 | const gchar *object_path, 165 | GCancellable *cancellable, 166 | GAsyncReadyCallback callback, 167 | gpointer user_data); 168 | OrgBluezProfile1 *org_bluez_profile1_proxy_new_finish ( 169 | GAsyncResult *res, 170 | GError **error); 171 | OrgBluezProfile1 *org_bluez_profile1_proxy_new_sync ( 172 | GDBusConnection *connection, 173 | GDBusProxyFlags flags, 174 | const gchar *name, 175 | const gchar *object_path, 176 | GCancellable *cancellable, 177 | GError **error); 178 | 179 | void org_bluez_profile1_proxy_new_for_bus ( 180 | GBusType bus_type, 181 | GDBusProxyFlags flags, 182 | const gchar *name, 183 | const gchar *object_path, 184 | GCancellable *cancellable, 185 | GAsyncReadyCallback callback, 186 | gpointer user_data); 187 | OrgBluezProfile1 *org_bluez_profile1_proxy_new_for_bus_finish ( 188 | GAsyncResult *res, 189 | GError **error); 190 | OrgBluezProfile1 *org_bluez_profile1_proxy_new_for_bus_sync ( 191 | GBusType bus_type, 192 | GDBusProxyFlags flags, 193 | const gchar *name, 194 | const gchar *object_path, 195 | GCancellable *cancellable, 196 | GError **error); 197 | 198 | 199 | /* ---- */ 200 | 201 | #define TYPE_ORG_BLUEZ_PROFILE1_SKELETON (org_bluez_profile1_skeleton_get_type ()) 202 | #define ORG_BLUEZ_PROFILE1_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_ORG_BLUEZ_PROFILE1_SKELETON, OrgBluezProfile1Skeleton)) 203 | #define ORG_BLUEZ_PROFILE1_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_ORG_BLUEZ_PROFILE1_SKELETON, OrgBluezProfile1SkeletonClass)) 204 | #define ORG_BLUEZ_PROFILE1_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_ORG_BLUEZ_PROFILE1_SKELETON, OrgBluezProfile1SkeletonClass)) 205 | #define IS_ORG_BLUEZ_PROFILE1_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_ORG_BLUEZ_PROFILE1_SKELETON)) 206 | #define IS_ORG_BLUEZ_PROFILE1_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_ORG_BLUEZ_PROFILE1_SKELETON)) 207 | 208 | typedef struct _OrgBluezProfile1Skeleton OrgBluezProfile1Skeleton; 209 | typedef struct _OrgBluezProfile1SkeletonClass OrgBluezProfile1SkeletonClass; 210 | typedef struct _OrgBluezProfile1SkeletonPrivate OrgBluezProfile1SkeletonPrivate; 211 | 212 | struct _OrgBluezProfile1Skeleton 213 | { 214 | /*< private >*/ 215 | GDBusInterfaceSkeleton parent_instance; 216 | OrgBluezProfile1SkeletonPrivate *priv; 217 | }; 218 | 219 | struct _OrgBluezProfile1SkeletonClass 220 | { 221 | GDBusInterfaceSkeletonClass parent_class; 222 | }; 223 | 224 | GType org_bluez_profile1_skeleton_get_type (void) G_GNUC_CONST; 225 | 226 | #if GLIB_CHECK_VERSION(2, 44, 0) 227 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (OrgBluezProfile1Skeleton, g_object_unref) 228 | #endif 229 | 230 | OrgBluezProfile1 *org_bluez_profile1_skeleton_new (void); 231 | 232 | 233 | G_END_DECLS 234 | 235 | #endif /* __PROFILE1_IFACE_H__ */ 236 | --------------------------------------------------------------------------------