Today's Menu  Portugal
journal and plan nutrition
Z5GoogleCalendarDataController.m
Go to the documentation of this file.
1 //
2 // Z5GoogleCalendarController.m
3 // TodaysMenu
4 //
5 // Created by Don Zeek on 4/25/18.
6 // Copyright © 2018 net.dzeek.y2015.ios.portfolio. All rights reserved.
7 //
8 
11 #import "Z5DataController.h"
12 
13 @implementation Z5GoogleCalendarDataController {
14  NSMutableArray *localCalendarListeners;
15 }
16 
17 - (id) init
18 {
19  // Initialize the service object.
20  self.service = [[GTLRCalendarService alloc] init];
21 
22  localCalendarListeners = [[NSMutableArray alloc] initWithCapacity:10];
23 
24  return self;
25 }
26 
27 
28 - (void) addCalendarListener: (id<Z5GoogleCalendarListener>)ear
29 {
30  [self connectToLogin];
31  [localCalendarListeners addObject:ear];
32 }
33 - (void) removeCalendarListener: (id<Z5GoogleCalendarListener>)ear
34 {
35  [localCalendarListeners removeObject:ear];
36 }
37 - (void) connectToLogin
38 {
39  Z5GoogleLoginController *loginControl = [[[Z5DataController sharedInstance] remoteDataController] loginController];
40  [loginControl addLoginListener:self];
41 }
42 
43 #pragma mark - Z5GoogleLoginListener
44 - (void) signedIn: (GIDGoogleUser *)user
45 {
46  NSLog(@"GoogleCalendarController.signedIn: %@", user.profile.name);
47  self.service.authorizer = user.authentication.fetcherAuthorizer;
48 }
49 - (void) signedOut:(GIDGoogleUser *)user
50 {
51  self.service.authorizer = nil;
52 }
53 
54 
55 @end
GIDProfileData * profile
Definition: GIDGoogleUser.h:24
void addLoginListener:(id< Z5GoogleLoginListener > ear)
instancetype sharedInstance()
id< GTMFetcherAuthorizationProtocol > fetcherAuthorizer()
Singleton interface to both core and remote data sources.
NSString * name
GIDAuthentication * authentication
Definition: GIDGoogleUser.h:27