Skip to content

Commit

Permalink
blueman-sendto: Do not try to send a file during discovery
Browse files Browse the repository at this point in the history
It looks like there are controllers that cause a fail in that situation, so we need to wait until the discovery is done.

Fixes #463
  • Loading branch information
cschramm committed Feb 29, 2016
1 parent 27bad4d commit 0951b20
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 2-0-stable (unreleased)

### Changes

* Do not try to send a file during a discovery

## 2.0.3

Fix privilege escalation
Expand Down
7 changes: 7 additions & 0 deletions apps/blueman-sendto
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ from blueman.Constants import *
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
from gi.repository import GObject

from blueman.bluez.Adapter import Adapter
from blueman.bluez.obex.ObjectPush import ObjectPush
Expand Down Expand Up @@ -130,6 +131,12 @@ class Sender(GObject.GObject):
self.window.show()

def create_session(self):
if self.adapter.get_properties()['Discovering']:
GObject.timeout_add(1000, self.create_session)
else:
self._do_create_session()

def _do_create_session(self):
dprint("Creating session")
props = self.adapter.get_properties()
self.client.create_session(self.device.Address, props["Address"])
Expand Down

2 comments on commit 0951b20

@infirit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't use GLib function indirectly through GObject, it will work but produces warnings.

The timeout only ever wait a single second before call the function. Here [1] is a gist of what I was thinking about when I suggested it's use 😄 .

[1] https://gist.github.com/infirit/75402fc8fdbaa2d973f5

@cschramm
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I got timeout_add wrong. Next try: f7c0f6a

Please sign in to comment.