def sending_file_action(self, widget): '''Action invoked when send file is sending''' device = self.get_working_device() if device != None: bm = BluetoothManager() bm.send_file_obex((device['mac'], self.chooseFile_chooserdialog.get_filename())) self.sendProgress_messagedialog.hide() self.move_progress_bar_flag = False
def scan_for_devices_action(self, nothing): '''Method used to discover new devices''' bm = BluetoothManager() self.devices = bm.discover_devices() self.tree_store = gtk.TreeStore(str) for device in self.devices: self.tree_store.append(None, ['%s [%s]' % (device['name'], device['mac'])]) self.tree_view.set_model(self.tree_store) self.on_finish_scan_action(None)
def list_devices_action(self, nothing): '''Method used to list devices in system''' bm = BluetoothManager() while self.is_running: self.working_devices = bm.list_devices() self.working_tree_store = gtk.TreeStore(str) for device in self.working_devices: self.working_tree_store.append(None, ['%s [%s]' % (device['name'], device['mac'])]) self.working_tree_view.set_model(self.working_tree_store) time.sleep(5)
def show_rfcomm(self, widget): '''Action invoked after rfcomm button click''' bm = BluetoothManager() self.rfcomm_session = bm.connect_rfcomm_device(self.get_working_device()['mac']) if self.rfcomm_session.__class__ == BluetoothManager: thread = MyThread(self.receive_rfcomm_msg) self.threads.append(thread) thread.start() textview = self.builder.get_object("send_textview").get_buffer() textview.delete(textview.get_start_iter(), textview.get_end_iter()) textview = self.builder.get_object("received_textview").get_buffer() textview.delete(textview.get_start_iter(), textview.get_end_iter()) self.rfcomm_dialog.run() else: print 'kod: ' + str(self.rfcomm_session)