Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Auto refresh unloaded Safari pages on AirPort link up' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Auto refresh unloaded Safari pages on AirPort link up
Authored by: sabi on Dec 06, '05 04:07:48PM
Yes, you can use SCNetworkReachability to register a callback.

I wrote a Python wrapper for it, which you can find in my LocationDo project (note that LocationDo is a general-purpose app at all, it does only exactly what I want, but you should be able to adapt it to do what you want). You can see how I use it in action.py:

class _LDURLWatcher(NSObject):
    def URLIsReachable_(self, notification):
        _openURL(notification.object())

_urlWatcher = _LDURLWatcher.alloc().init()
NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(
    _urlWatcher, 'URLIsReachable:', SCNetworkReachability.SCNetworkIsReachable,
    None)

def openURL(url):
    hostname = NSURL.URLWithString_(url).host()
    if not SCNetworkReachability.notify_when_reachable(hostname, url):
        _openURL(url)
That'll give you exactly Safari-like behavior—the URL opening will be postponed until the connection is up. I use it for exactly what you describe, opening the login pages.

[ Reply to This | # ]