Mercurial > audlegacy-plugins
annotate src/bluetooth/bluetooth.c @ 2840:50507763fd31
working basic pairing / bounding
author | Paula Stanciu <paula.stanciu@gmail.com> |
---|---|
date | Fri, 18 Jul 2008 11:46:56 +0300 |
parents | 22a5075fc7f7 |
children | 9637eab5a3dd |
rev | line source |
---|---|
2839 | 1 /* |
2 * Audacious Bluetooth headset suport plugin | |
3 * | |
4 * Copyright (c) 2008 Paula Stanciu paula.stanciu@gmail.com | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; under version 3 of the License. | |
9 * | |
10 * This program is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License | |
16 * along with this program. If not, see <http://www.gnu.org/licenses>. | |
17 */ | |
18 | |
2644 | 19 #include "bluetooth.h" |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
20 #include "marshal.h" |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
21 #include "gui.h" |
2728 | 22 #include "scan_gui.h" |
2838
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
23 #include "agent.h" |
2644 | 24 #define DEBUG 1 |
25 static gboolean plugin_active = FALSE,exiting=FALSE; | |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
26 GList * current_device = NULL; |
2728 | 27 gint config = 0; |
28 gint devices_no = 0; | |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
29 GStaticMutex mutex = G_STATIC_MUTEX_INIT; |
2644 | 30 |
31 void bluetooth_init ( void ); | |
32 void bluetooth_cleanup ( void ); | |
33 void bt_cfg(void); | |
34 void bt_about(void); | |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
35 static void remote_device_found(DBusGProxy *object, char *address, const unsigned int class, const int rssi, gpointer user_data); |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
36 static void discovery_started(DBusGProxy *object, gpointer user_data); |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
37 static void remote_name_updated(DBusGProxy *object, const char *address, char *name, gpointer user_data); |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
38 static void print_results(void); |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
39 static void discovery_completed(DBusGProxy *object, gpointer user_data); |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
40 void discover_devices(void); |
2728 | 41 void disconnect_dbus_signals(void); |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
42 |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
43 |
2644 | 44 GeneralPlugin bluetooth_gp = |
45 { | |
2649
d891ba4be5a5
fixed crash when prefs window was closed while scanning
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2648
diff
changeset
|
46 .description = "Bluetooth audio support", |
2644 | 47 .init = bluetooth_init, |
48 .about = bt_about, | |
49 .configure = bt_cfg, | |
50 .cleanup = bluetooth_cleanup | |
51 }; | |
52 GeneralPlugin *bluetooth_gplist[] = { &bluetooth_gp, NULL }; | |
53 DECLARE_PLUGIN(bluetooth_gp, NULL, NULL, NULL, NULL, NULL, bluetooth_gplist, NULL, NULL) | |
2728 | 54 |
2644 | 55 void bluetooth_init ( void ) |
56 { | |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
57 audio_devices = NULL; |
2838
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
58 bus = NULL; |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
59 obj = NULL; |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
60 discover_devices(); |
2644 | 61 } |
62 | |
63 void bluetooth_cleanup ( void ) | |
64 { | |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
65 printf("bluetooth: exit\n"); |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
66 if (config ==1 ){ |
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2734
diff
changeset
|
67 close_window(); |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
68 config =0; |
2649
d891ba4be5a5
fixed crash when prefs window was closed while scanning
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2648
diff
changeset
|
69 } |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
70 if(discover_finish == 2) { |
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
71 dbus_g_connection_flush (bus); |
2734 | 72 dbus_g_connection_unref(bus); |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
73 disconnect_dbus_signals(); |
2644 | 74 |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
75 } |
2734 | 76 } |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
77 |
2734 | 78 void bt_about( void ) |
79 { | |
80 printf("about call\n"); | |
81 } | |
2728 | 82 |
2734 | 83 void bt_cfg(void) |
84 { | |
85 printf("bt_cfg\n"); | |
86 config =1; | |
87 if(discover_finish == 2){ | |
88 if (devices_no == 0){ | |
89 printf("no devs!\n"); | |
90 show_scan(); | |
91 show_no_devices(); | |
92 }else | |
93 results_ui(); | |
2728 | 94 } |
2734 | 95 else show_scan(); |
96 printf("end of bt_cfg\n"); | |
97 } | |
2728 | 98 |
2734 | 99 void disconnect_dbus_signals() |
100 { | |
101 dbus_g_proxy_disconnect_signal(obj, "RemoteDeviceFound", G_CALLBACK(remote_device_found), bus); | |
102 dbus_g_proxy_disconnect_signal(obj, "DiscoveryStarted", G_CALLBACK(discovery_started), bus); | |
103 dbus_g_proxy_disconnect_signal(obj, "DiscoveryCompleted", G_CALLBACK(discovery_completed), bus); | |
104 dbus_g_proxy_disconnect_signal(obj, "RemoteNameUpdated", G_CALLBACK(remote_name_updated), NULL); | |
2644 | 105 |
2734 | 106 } |
2644 | 107 |
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2734
diff
changeset
|
108 void clean_devices_list(){ |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2734
diff
changeset
|
109 g_list_free(audio_devices); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2734
diff
changeset
|
110 dbus_g_connection_flush (bus); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2734
diff
changeset
|
111 dbus_g_connection_unref(bus); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2734
diff
changeset
|
112 audio_devices = NULL; |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2734
diff
changeset
|
113 //g_list_free(current_device); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2734
diff
changeset
|
114 } |
2644 | 115 |
2734 | 116 void refresh_call(void) |
117 { | |
118 printf("refresh function called\n"); | |
119 disconnect_dbus_signals(); | |
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2734
diff
changeset
|
120 clean_devices_list(); |
2734 | 121 if(discover_finish == 0 ||discover_finish== 2){ |
122 discover_finish = 0; | |
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2734
diff
changeset
|
123 |
2734 | 124 discover_devices(); |
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2734
diff
changeset
|
125 close_window(); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2734
diff
changeset
|
126 show_scan(); |
2728 | 127 } |
2734 | 128 else |
129 printf("Scanning please wait!\n"); | |
130 } | |
2644 | 131 |
2838
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
132 void bounding_created(gchar* address) |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
133 { |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
134 printf("Signal BoundingCreated : %s\n",address); |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
135 |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
136 } |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
137 |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
138 void bounding_removed(gchar* address) |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
139 { |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
140 printf("Signal: BoundingRemoved: %s\n",address); |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
141 |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
142 } |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
143 |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
144 |
2734 | 145 void connect_call(void) |
146 { | |
2838
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
147 |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
148 //I will have to enable the audio service if necessary |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
149 |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
150 /* dbus_g_object_register_marshaller(marshal_VOID__STRING_UINT_INT, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID); |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
151 dbus_g_proxy_add_signal(obj, "BondingCreated", G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID); |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
152 dbus_g_proxy_connect_signal(obj, "BondingCreated", G_CALLBACK(bounding_created), bus, NULL); |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
153 |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
154 dbus_g_proxy_add_signal(obj, "BondingRemoved", G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID); |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
155 dbus_g_proxy_connect_signal(obj, "BondingRemoved", G_CALLBACK(bounding_removed), bus, NULL); |
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
156 */ |
2840
50507763fd31
working basic pairing / bounding
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
157 run_agents(); |
2838
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
158 dbus_g_proxy_call(obj,"CreateBonding",NULL,G_TYPE_STRING,"00:0D:3C:B1:1C:7A",G_TYPE_INVALID,G_TYPE_INVALID); |
2840
50507763fd31
working basic pairing / bounding
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
159 |
2838
22a2ffe86750
added passkey agent and basic pairing functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2756
diff
changeset
|
160 |
2734 | 161 } |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
162 |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
163 |
2734 | 164 static void remote_device_found(DBusGProxy *object, char *address, const unsigned int class, const int rssi, gpointer user_data) |
165 { | |
166 int found_in_list=FALSE; | |
167 g_static_mutex_lock(&mutex); | |
168 current_device = audio_devices; | |
169 if((class & 0x200404)==0x200404) | |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
170 { |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
171 while(current_device != NULL) |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
172 { |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
173 if(g_str_equal(address,((DeviceData*)(current_device->data))->address)) |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
174 { |
2734 | 175 found_in_list = TRUE; |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
176 break; |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
177 } |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
178 current_device=g_list_next(current_device); |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
179 } |
2734 | 180 if(!found_in_list) |
181 { | |
182 DeviceData *dev= g_new0(DeviceData, 1); | |
183 dev->class = class; | |
184 dev->address = g_strdup(address); | |
185 dev->name = NULL; | |
186 audio_devices=g_list_prepend(audio_devices, dev); | |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
187 } |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
188 } |
2734 | 189 g_static_mutex_unlock(&mutex); |
190 } | |
191 | |
192 static void discovery_started(DBusGProxy *object, gpointer user_data) | |
193 { | |
194 g_print("Signal: DiscoveryStarted()\n"); | |
195 discover_finish = 1; | |
196 } | |
197 | |
198 static void remote_name_updated(DBusGProxy *object, const char *address, char *name, gpointer user_data) | |
199 { | |
200 g_static_mutex_lock(&mutex); | |
201 current_device=audio_devices; | |
202 while(current_device != NULL) | |
203 { | |
204 if(g_str_equal(address,((DeviceData*)(current_device->data))->address)) | |
205 { | |
206 ((DeviceData*)(current_device->data))->name=g_strdup(name); | |
207 break; | |
208 } | |
209 current_device=g_list_next(current_device); | |
210 } | |
211 g_static_mutex_unlock(&mutex); | |
212 } | |
213 | |
214 static void print_results() | |
215 { | |
216 int i=0; | |
217 g_print("Final Scan results:\n"); | |
218 devices_no = g_list_length(audio_devices); | |
219 g_print("Number of audio devices: %d \n",devices_no); | |
220 if(devices_no==0 ) { | |
221 if(config ==1) show_no_devices(); | |
222 } else { | |
223 current_device=audio_devices; | |
224 while(current_device != NULL) | |
225 { | |
226 g_print("Device %d: Name: %s, Class: 0x%x, Address: %s\n",++i, | |
227 ((DeviceData*)(current_device->data))-> name, | |
228 ((DeviceData*)(current_device->data))-> class, | |
229 ((DeviceData*)(current_device->data))-> address); | |
230 current_device=g_list_next(current_device); | |
231 } | |
232 destroy_scan_window(); | |
233 if(config==1) { | |
234 destroy_scan_window(); | |
235 results_ui(); | |
236 } | |
237 // refresh_tree(); | |
238 } | |
239 } | |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
240 |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
241 |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
242 |
2734 | 243 static void discovery_completed(DBusGProxy *object, gpointer user_data) |
244 { | |
245 g_print("Signal: DiscoveryCompleted()\n"); | |
246 discover_finish =2; | |
247 print_results(); | |
248 } | |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
249 |
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
250 |
2728 | 251 |
2734 | 252 void discover_devices(void) |
253 { | |
254 GError *error = NULL; | |
255 // g_type_init(); | |
256 g_log_set_always_fatal (G_LOG_LEVEL_WARNING); | |
257 bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); | |
258 if (error != NULL) | |
259 { | |
260 g_printerr("Connecting to system bus failed: %s\n", error->message); | |
261 g_error_free(error); | |
262 } | |
263 obj = dbus_g_proxy_new_for_name(bus, "org.bluez", "/org/bluez/hci0", "org.bluez.Adapter"); | |
264 printf("bluetooth plugin - start discovery \n"); | |
265 dbus_g_object_register_marshaller(marshal_VOID__STRING_UINT_INT, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID); | |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
266 |
2734 | 267 dbus_g_proxy_add_signal(obj, "RemoteDeviceFound", G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID); |
268 dbus_g_proxy_connect_signal(obj, "RemoteDeviceFound", G_CALLBACK(remote_device_found), bus, NULL); | |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
269 |
2734 | 270 dbus_g_proxy_add_signal(obj, "DiscoveryStarted", G_TYPE_INVALID); |
271 dbus_g_proxy_connect_signal(obj, "DiscoveryStarted", G_CALLBACK(discovery_started), bus, NULL); | |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
272 |
2734 | 273 dbus_g_proxy_add_signal(obj, "DiscoveryCompleted", G_TYPE_INVALID); |
274 dbus_g_proxy_connect_signal(obj, "DiscoveryCompleted", G_CALLBACK(discovery_completed), bus, NULL); | |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
275 |
2734 | 276 dbus_g_object_register_marshaller(marshal_VOID__STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); |
2728 | 277 |
2734 | 278 dbus_g_proxy_add_signal(obj, "RemoteNameUpdated", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); |
279 dbus_g_proxy_connect_signal(obj, "RemoteNameUpdated", G_CALLBACK(remote_name_updated), NULL, NULL); | |
2646
7fbff3287a56
added device discovery in the plugin's prefs window
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2644
diff
changeset
|
280 |
2734 | 281 dbus_g_proxy_call(obj, "DiscoverDevices", &error, G_TYPE_INVALID, G_TYPE_INVALID); |
282 if (error != NULL) | |
283 { | |
284 g_printerr("Failed to discover devices: %s\n", error->message); | |
285 g_error_free(error); | |
286 } | |
2728 | 287 |
2734 | 288 } |