Skip to content

Airport module rewrite#63

Merged
HenningJ merged 99 commits intoquicksilver:masterfrom
skurfer:airport
Jul 27, 2011
Merged

Airport module rewrite#63
HenningJ merged 99 commits intoquicksilver:masterfrom
skurfer:airport

Conversation

@skurfer
Copy link
Member

@skurfer skurfer commented May 30, 2011

Who else is tired of this plug-in’s bad reputation? :)

I thought I just needed to update the function that listed networks, but it ended up being a complete rewrite. (I wouldn’t even bother trying to look at diffs. Might as well just read over the code.)

Changes from the old behavior

Catalog

This doesn’t add any networks (available or preferred) to the catalog. Available networks don’t really belong there because they come and go and most of them probably mean nothing to you. Also, the catalog updates every 10 minutes at best. Do you really want to open your laptop and wait 10 minutes before attempting to connect to a network? And how would you know what to search for anyway? As for preferred networks, what could you do with them other than connect? So what good would it do to have access to a preferred network if it wasn’t also an available network?

With all that in mind, only one item called “AirPort” is added to the catalog. Its children are the available networks (scanned in real-time). The only thing I wish it did was indicate the network you’re connected to on the list somehow, but I didn’t see an obvious way to do that.

Actions

There were actions to turn AirPort on and off. Only one of the two could possibly work at any given time, so why make the user pick one? There are still on and off actions because it looks nicer than “toggle”, but you don’t have to pick one. The appropriate one will be selected by default.

HenningJ and others added 30 commits April 8, 2011 13:27
* The proxy object no longer runs AppleScript unconditionally (causing OmniWeb to launch if it wasn't running)
* The proxy has been renamed to "Current Web Page" to match Safari's

also set an icon for the plug-in itself
Added a new object type QSSearchURLType.
Also fixed for strange characters in URLs for Search for... actions
I've:
Made the encoding of URLs default to NSUTF8Encoding
Speeded up the validActionsForObject method by just checking the primaryType
Fixed another bug I came across: Search for terms with % in e.g. 'I got 100%'
Here's what now happens:
@HenningJ
Copy link
Contributor

@pjrobertson
Copy link
Member

Searching around leads me to believe that the scale is between -100 and 0,
but anything over -60 is considered full strength,

If the strength is going from - something to 0, then the scale is probably
decibel (dB). Plus dB is normally what you use for power.
My thoughts are that the strength goes from 0.001 to 1 which corresponds
with -60dB to 0dB

To convert decimal to dB you use: y = 20*log(x)
To convert dB to decimal you use: x = 10^(y/20)

Who would've thought engineering would come in handy eh?!

If you like it, I could make proper icons for all strengths.

Those icons look good Henning :)

I had the same thought, but I was unable to find a suitable unicode
character.

For some reason this won't show up, so I don't know if it's right:

http://www.fileformat.info/info/unicode/char/9501/index.htm or

http://www.fileformat.info/info/unicode/char/1f512/index.htm

On 21 June 2011 03:10, skurfer <
reply@reply.github.com>wrote:

I found the signal strength icons Apple uses and incorporated them. Im
mostly guessing on how many bars to show. Searching around leads me to
believe that the scale is between -100 and 0, but anything over -60 is
considered full strength, so splitting it in 1/4ths would be incorrect.
This can be adjusted as experience gives us more data.

I also found standard, supported ways to check for preferred networks and
look up passwords for secure networks.

The one remaining problem is that if you try to connect to a secure network
for which you have no password stored, it will fail silently. I would expect
the OS to prompt for a password here, but that must be handled by the
wireless menu widget instead. One way to solve this is to disable the
Select Network action if theres no passphrase for a secure network. The
other is to create some UI to get it, which is not trivial.

Reply to this email directly or view it on GitHub:
#63 (comment)

@HenningJ
Copy link
Contributor

Btw. you can just open .icns files with Preview.app, drag out the individual image files for each size, modify them and build a new .icns file with /Developer/Applications/Utilities/Icon Composer.app

@pjrobertson: those characters show up as empty rectangles for me. That's because that server doesn't have a font installed that supports that characters. And I guess most Mac OS users wont either.

@HenningJ
Copy link
Contributor

The one remaining problem is that if you try to connect to a secure network for which you have no password stored,
it will fail silently.

Does it fail silently or is it that you can detect the failure, but can't really do anything about it?

One way to solve this is to disable the “Select Network” action if there’s no passphrase for a secure network.

I would go with this. But also somehow make that known in the network's QSObject's label or name.
Or leave the "Select Network" action active and play a error sound if it failed and show a notification with a short explanation what happen ("WiFi connection failed. No password stored. Connect manually." Or something like that).

@skurfer
Copy link
Member Author

skurfer commented Jun 21, 2011

The icons look great. I’ve incorporated them.

Btw. you can just open .icns files with Preview.app, drag out the individual image files for each size, modify them and build a new .icns file with /Developer/Applications/Utilities/Icon Composer.app

I figured it was easy, I just never had time to look into it. Thanks for the tip.

My thoughts are that the strength goes from 0.001 to 1 which corresponds with -60dB to 0dB

They say it’s a measure of how much is lost between source and destination. So 0 is perfect and it goes down from there. Here at work, I’m showing four “bars” with an RSSI of -66. I can get more data at home where there are over a dozen networks. I’ll add some NSLogs and compare the numbers to the “bars” in the menu item’s UI and see if I can come up with a better scale.

Does it fail silently or is it that you can detect the failure, but can't really do anything about it?

I suppose it’s currently only silent because I haven’t written any code to check for failure. There’s an NSError object we could look at, but like I said, I don’t want to write the UI to get the password and try again. Maybe a notification would be best.

@pjrobertson
Copy link
Member

They say its a measure of how much is lost between source and
destination. So 0 is perfect and it goes down from there

Aaah OK fair enough :)
Just keep in mind that the scale may not be linear ;)

... I dont want to write the UI to get the password and try again. Maybe
a notification would be best...

Have you considered removing the 'Select Network' action for these wireless
networks, but adding a 'Select Network with Password...' action (with an
iObject) instead as the default?
That could work quite nicely. No need for a UI rewrite, would indicate to
the user that a password is required, and would be best for the user (e.g.
if you know the password, you don't have to go use something other than
Quicksilver)

On 21 June 2011 23:48, skurfer <
reply@reply.github.com>wrote:

The icons look great. Ive incorporated them.

Btw. you can just open .icns files with Preview.app, drag out the
individual image files for each size, modify them and build a new .icns file
with /Developer/Applications/Utilities/Icon Composer.app

I figured it was easy, I just never had time to look into it. Thanks for
the tip.

My thoughts are that the strength goes from 0.001 to 1 which corresponds
with -60dB to 0dB

They say its a measure of how much is lost between source and destination.
So 0 is perfect and it goes down from there. Here at work, Im showing four
bars with an RSSI of -66. I can get more data at home where there are over
a dozen networks. Ill add some NSLogs and compare the numbers to the bars
in the menu items UI and see if I can come up with a better scale.

Does it fail silently or is it that you can detect the failure, but can't
really do anything about it?

I suppose its currently only silent because I havent written any code to
check for failure. Theres an NSError object we could look at, but like I
said, I dont want to write the UI to get the password and try again. Maybe
a notification would be best.

Reply to this email directly or view it on GitHub:
#63 (comment)

@HenningJ
Copy link
Contributor

Have you considered removing the 'Select Network' action for these wireless
networks, but adding a 'Select Network with Password...' action (with an
iObject) instead as the default?
That could work quite nicely. No need for a UI rewrite, would indicate to
the user that a password is required, and would be best for the user (e.g.
if you know the password, you don't have to go use something other than
Quicksilver)

Two things:

  1. most likely you will need a username as well as a password, wont you? So you'll need to think of some scheme to enter both in the one iObject textfield.
  2. for some reason, I wouldn't be comfortable entering a password in the Quicksilver interface. There is a reason why password fields a normally masked: So people can't easily look over your shoulder and see your super secret password (which you maybe use for everything else as well). So entering a password in a non-password-textfield just feels wrong.

@skurfer
Copy link
Member Author

skurfer commented Jun 21, 2011

I think Patrick’s on to something. When creating the network objects, I can check to see if it’s secure, but not preferred and store a boolean in the metadata. Then the action validator can check this value (rather than repeating tests that were done when the object was created) and decide which action to display.

As far as I know, there’s never a username and the credentials you enter are not associated with you. You typically need the SSID (which is usually broadcast) and the “key”, which is the passphrase you type. The key is usually written on a whiteboard in a class, or printed on your receipt in a café, etc. I don’t think shoulder-surfing is a big deal for this, but we can leave that up to the user, right? The only remaining downside I see here is that you wouldn’t get an opportunity to store the network/passphrase for future connections.

Note that this is about the “physical” connection to the network. There are some networks where you log in with a personal account, but that is usually done in a web interface after the connection is established.

@HenningJ
Copy link
Contributor

Well, right now I'm surfing on my university's wifi network, which uses a WPA2 / 802.1X / TTLS authentication (whatever all those acronyms mean ;-)), which needs username and password to connect to the network. But I guess that's a special case, which needs to configured manually anyway.

So I guess it would be ok to do what patrick suggested. BUT...

The only remaining downside I see here is that you wouldn’t get an opportunity to store the network/passphrase for future connections.

That'd be annoying. If this is that case, I'd prefer to be notified that I need to log in manually ONE TIME, so my credentials can be stored in the keychain.
If you could solve this, I'd be really happy with this solution. I'm sure there must be an API to store wifi network credentials in the keychain.

@skurfer
Copy link
Member Author

skurfer commented Jun 21, 2011

We’d need to store the network on the preferred list in addition to the keychain stuff. I’ve found that you can get the passphrase out of the keychain very easily by using CWWirelessProfile. The docs say that the properties are all read/write, but it’s not clear to me how you would store the profile after you get the object set up. (Can anyone tell?) If that’s even possible, I imagine it handles the keychain piece transparently.

@HenningJ
Copy link
Contributor

It's a readwrite property, so it should just work with setPassphrase, shouldn't it?

And why does it need to be stored as preferred network? Just because I connected to a network once doesn't I prefer it.

@skurfer
Copy link
Member Author

skurfer commented Jun 22, 2011

It's a readwrite property, so it should just work with setPassphrase, shouldn't it?

Yes, so we can set the profile up just how we want it, but like I said, how would I store it on the preferred list?

And why does it need to be stored as preferred network? Just because I connected to a network once doesn't I prefer it.

If you check the “Remember this network” box when connecting, it goes on the preferred list. It just means you won’t be prompted to connect the next time that network is in range. Now that I think about it, people might want to do this for unsecured networks as well, but we shouldn’t make the assumption for them in either case. Maybe we should allow the connect action only for preferred networks. I wonder if we could somehow use AppleScript to activate the menubar item’s connect UI for the others.

Let’s back up a minute. There are many issues with connecting that would be difficult to address with Quicksilver’s standard 2 or 3 pane UI. I’d almost forgotten at this point, but now I remember: I never saw much value in this plug-in[^1] and I don’t imagine that many others will either. I just wondered if it would be easy to update to prevent crashing and I ended up figuring it out.

Instead of comparing this to a perfect AirPort module that could be, can we compare it to the AirPort module that actually exists? It makes Quicksilver crash. :)

[1]: Actually, I use it to turn power on and off all the time now that the UI for doing so is improved, but I’ll likely never use it to browse and connect to networks.

@HenningJ
Copy link
Contributor

Instead of comparing this to a perfect AirPort module that could be, can we compare it to the AirPort
module that actually exists? It makes Quicksilver crash. :)

Yeah. That's why I said just throw up a notification if there is any trouble and let the user handle that himself manually. :-)
If you do that, I'm absolutely happy with and I'd say it already has by far surpassed the original (even when it was stil working ;-)).

@skurfer
Copy link
Member Author

skurfer commented Jun 22, 2011

I’ll spend some time investigating the AppleScript option I mentioned, but if not, I’ll resort to notifications.

@skurfer
Copy link
Member Author

skurfer commented Jun 23, 2011

Alright, give this a whirl.

@HenningJ
Copy link
Contributor

Not bad. Not perfect, but pretty close. :-)
The first time you open the Airport menu bar thing, the network you selected in QS wont be there, because it has to load all the networks first, so the click wont work. So it will just open the airport menu bar menu, but not actually click the network.
It will work the second time you try it, because then the networks are already loaded.

One more thing I would like: make the AirPort QSObject the parent of the networks. So you can right-arrow out of the networks again. Just feels more consistent. :-)

@skurfer
Copy link
Member Author

skurfer commented Jun 23, 2011

The first time you open the Airport menu bar thing, the network you selected in QS wont be there, because it has to load all the networks first, so the click wont work.

Hmmm. I didn’t run into this. I must have clicked the menu item at some point before testing. Should we introduce a delay? (We’d just be guessing as to how long.) Or should we scrap all the network objects and just use this plug-in to turn power on and off? :)

One more thing I would like: make the AirPort QSObject the parent of the networks.

Line 88: [newObject setParentID:[object identifier]]; I did this right away when rewriting the plug-in. I also noticed right away that it wasn’t working. Any ideas?

@HenningJ
Copy link
Contributor

hmm...I noticed in the Mail.app plugin the first level of child objects works without setting the parentID. But here it doesn't work either way. Strange.

ok...from a quick look at QSSearchObjectView browse:direction:, QS doesn't actually save the result list before right-arrowing, so it can't use that repopulate the list when left-arrowing back out. When you are right-arrowing back out, it rather looks at the parent of the current object's parent, takes its children and uses them to repopulate the list.
That works for the Mail.app's children, because the Mail.app object has a parent (the /Applications folder). But it wont work for the Airport object, because that's a root object in the catalog.

So, not a problem of your plugin, but rather QS itself. Another part of QS that needs a major overhaul. ;-)

Hmmm. I didn’t run into this. I must have clicked the menu item at some point before testing. Should
we introduce a delay? (We’d just be guessing as to how long.) Or should we scrap all the network
objects and just use this plug-in to turn power on and off? :)

Can you try immediately, and if it didn't work try again after a delay. We wouldn't want a delay if it would have worked right away.

@skurfer
Copy link
Member Author

skurfer commented Jul 26, 2011

Oh, jeez. I just checked and the menu item, from AppleScript’s point of view, is now called “Wi-Fi, four of four bars, with [network name].” Slightly more difficult to match than “AirPort”. I’m about ready to declare that Quicksilver’s not the best way to connect to an unknown network.

@pjrobertson
Copy link
Member

There haven't been any updated APIs? I'd like to hope Apple have done
something to make it easier... :)

On 26 July 2011 18:38, skurfer <
reply@reply.github.com>wrote:

Oh, jeez. I just checked and the menu item, from AppleScripts point of
view, is now called Wi-Fi, four of four bars, with [network name].
Slightly more difficult to match than AirPort. Im about ready to declare
that Quicksilvers not the best way to connect to an unknown network.

Reply to this email directly or view it on GitHub:
#63 (comment)

@HenningJ
Copy link
Contributor

How about we release it as it is right now (because it works pretty well for SL). And then, once we figured out the best way to handle anything that's changed in Lion, we release a Lion version (which should be easy once we have a plugin system...:-)).

@skurfer
Copy link
Member Author

skurfer commented Jul 27, 2011

Sounds good. If you merge it, I’ll publish it. (We should also take this opportunity to put it in its own repo before further work continues.)

HenningJ added a commit that referenced this pull request Jul 27, 2011
@HenningJ HenningJ merged commit 2761ff4 into quicksilver:master Jul 27, 2011
@HenningJ
Copy link
Contributor

Yay, merged it. I'll also put it in it's own repo.

@pjrobertson
Copy link
Member

I'll chime in late... all sounds good to me :)

On 27 July 2011 14:11, HenningJ <
reply@reply.github.com>wrote:

Yay, merged it. I'll also put it in it's own repo.

Reply to this email directly or view it on GitHub:
#63 (comment)

@HenningJ
Copy link
Contributor

Good to have your approval. :-)
New repo is at https://github.com/quicksilver/AirPort-qsplugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants