diff options
Diffstat (limited to 'src/location-corelocation.m')
-rw-r--r-- | src/location-corelocation.m | 41 |
1 files changed, 12 insertions, 29 deletions
diff --git a/src/location-corelocation.m b/src/location-corelocation.m index 10d7acd..87eb0de 100644 --- a/src/location-corelocation.m +++ b/src/location-corelocation.m @@ -16,30 +16,13 @@ Copyright (c) 2014-2017 Jon Lund Steffensen <jonlst@gmail.com> */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include "common.h" #import <Foundation/Foundation.h> #import <CoreLocation/CoreLocation.h> -#include "location-corelocation.h" -#include "pipeutils.h" -#include "redshift.h" - -#include <stdio.h> -#include <unistd.h> - -#ifdef ENABLE_NLS -# include <libintl.h> -# define _(s) gettext(s) -#else -# define _(s) s -#endif - -typedef struct { +struct location_state { NSThread *thread; NSLock *lock; int pipe_fd_read; @@ -48,12 +31,12 @@ typedef struct { int error; float latitude; float longitude; -} location_corelocation_state_t; +}; @interface LocationDelegate : NSObject <CLLocationManagerDelegate> @property (strong, nonatomic) CLLocationManager *locationManager; -@property (nonatomic) location_corelocation_state_t *state; +@property (nonatomic) struct location_state *state; @end @implementation LocationDelegate; @@ -157,7 +140,7 @@ pipe_close_callback( @interface LocationThread : NSThread -@property (nonatomic) location_corelocation_state_t *state; +@property (nonatomic) struct location_state *state; @end @implementation LocationThread; @@ -194,15 +177,15 @@ pipe_close_callback( static int -location_corelocation_init(location_corelocation_state_t **state) +location_corelocation_init(struct location_state **state) { - *state = malloc(sizeof(location_corelocation_state_t)); + *state = malloc(sizeof(struct location_state)); if (*state == NULL) return -1; return 0; } static int -location_corelocation_start(location_corelocation_state_t *state) +location_corelocation_start(struct location_state *state) { state->pipe_fd_read = -1; state->pipe_fd_write = -1; @@ -235,7 +218,7 @@ location_corelocation_start(location_corelocation_state_t *state) } static void -location_corelocation_free(location_corelocation_state_t *state) +location_corelocation_free(struct location_state *state) { if (state->pipe_fd_read != -1) { close(state->pipe_fd_read); @@ -253,21 +236,21 @@ location_corelocation_print_help(FILE *f) static int location_corelocation_set_option( - location_corelocation_state_t *state, const char *key, const char *value) + struct location_state *state, const char *key, const char *value) { fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key); return -1; } static int -location_corelocation_get_fd(location_corelocation_state_t *state) +location_corelocation_get_fd(struct location_state *state) { return state->pipe_fd_read; } static int location_corelocation_handle( - location_corelocation_state_t *state, + struct location_state *state, location_t *location, int *available) { pipeutils_handle_signal(state->pipe_fd_read); |