diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-09-29 14:02:42 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-09-29 14:02:42 +0200 |
commit | 9e44c0eae8a5e13bfddd00c7888988cb0bfb7c1f (patch) | |
tree | f24560a75c45f10623c9d119cc2ff6097b18348d /macosx | |
parent | 135f68e249e4b01df7d9b5387a045bfb91bc4455 (diff) | |
download | qtlocation-mapboxgl-9e44c0eae8a5e13bfddd00c7888988cb0bfb7c1f.tar.gz |
add reachability
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/main.mm | 11 | ||||
-rw-r--r-- | macosx/mapboxgl-app.gyp | 3 |
2 files changed, 14 insertions, 0 deletions
diff --git a/macosx/main.mm b/macosx/main.mm index 7f22a32cc2..aeb49225cb 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -1,6 +1,7 @@ #include "../common/settings_nsuserdefaults.hpp" #include "../common/glfw_view.hpp" #include "../common/nslog_log.hpp" +#include "../common/Reachability.h" #import <Foundation/Foundation.h> @@ -75,12 +76,20 @@ int main() { GLFWView view; mbgl::Map map(view); + mbgl::Map *map_ptr = ↦ URLHandler *handler = [[URLHandler alloc] init]; [handler setMap:&map]; NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager]; [appleEventManager setEventHandler:handler andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; + // Notify map object when network reachability status changes. + Reachability* reachability = [Reachability reachabilityForInternetConnection]; + reachability.reachableBlock = ^(Reachability *reachability) { + map_ptr->setReachability(true); + }; + [reachability startNotifier]; + // Load settings mbgl::Settings_NSUserDefaults settings; map.setLonLatZoom(settings.longitude, settings.latitude, settings.zoom); @@ -100,6 +109,8 @@ int main() { int ret = view.run(); + [reachability stopNotifier]; + // Save settings map.getLonLatZoom(settings.longitude, settings.latitude, settings.zoom); settings.bearing = map.getBearing(); diff --git a/macosx/mapboxgl-app.gyp b/macosx/mapboxgl-app.gyp index 529da011a3..51f591fdd0 100644 --- a/macosx/mapboxgl-app.gyp +++ b/macosx/mapboxgl-app.gyp @@ -15,6 +15,8 @@ '../common/platform_nsstring.mm', '../common/glfw_view.hpp', '../common/glfw_view.cpp', + '../common/reachability.h', + '../common/reachability.m', '../common/http_request_baton_cocoa.mm', '../common/osx.mm', '../common/nslog_log.hpp', @@ -33,6 +35,7 @@ ], 'OTHER_LDFLAGS': [ '<@(glfw3_libraries)', + '-framework SystemConfiguration', ], 'SDKROOT': 'macosx', 'INFOPLIST_FILE': 'Info.plist', |