Today's Menu  Portugal
journal and plan nutrition
Instance Methods | Properties | List of all members
Z5GoogleLoginController Class Reference

#import <Z5GoogleLoginController.h>

Inheritance diagram for Z5GoogleLoginController:
Inheritance graph
[legend]
Collaboration diagram for Z5GoogleLoginController:
Collaboration graph
[legend]

Instance Methods

(void) - configureGoogleSignIn
 
(NSString *) - signedInUsername
 
(GIDProfileData *) - getLoggedInProfile
 
(void) - logOutGoogle
 
(void) - addLoginListener:
 
(void) - removeLoginListener:
 
(id) - init [implementation]
 
(void) - signIn:didSignInForUser:withError: [implementation]
 
(void) - signIn:didDisconnectWithUser:withError: [implementation]
 

Properties

NSNumber * signedIn
 
NSNumber * signInAttemptComplete
 
GIDGoogleUsersignedInUser
 
NSString * hostname
 
NSString * username
 
NSString * password
 

Detailed Description

Definition at line 16 of file Z5GoogleLoginController.h.

Method Documentation

◆ addLoginListener:()

- (void) addLoginListener: (id<Z5GoogleLoginListener>)  ear

Definition at line 106 of file Z5GoogleLoginController.m.

106  : (id<Z5GoogleLoginListener>)ear
107 {
108  if (![localLoginListeners containsObject:ear]) {
109  [localLoginListeners addObject:ear];
110  }
111  if (self.signedIn.boolValue) {
112  [ear signedIn: _signedInUser];
113  }
114 }

◆ configureGoogleSignIn()

- (void) configureGoogleSignIn

Definition at line 28 of file Z5GoogleLoginController.m.

29 {
30  [GIDSignIn sharedInstance].clientID = @"498458703530-8vl37k9m1ibmue9tkhod0imepvsvhttb.apps.googleusercontent.com";
31  [GIDSignIn sharedInstance].delegate = self;
32  [GIDSignIn sharedInstance].scopes = [NSArray arrayWithObjects:kGTLRAuthScopeGmailReadonly,
33  kGTLRAuthScopeDrive,
34  kGTLRAuthScopeCalendarReadonly,
35  nil];
36 }
GIDSignIn * sharedInstance()

◆ getLoggedInProfile()

- (GIDProfileData *) getLoggedInProfile

Definition at line 96 of file Z5GoogleLoginController.m.

97 {
99  GIDProfileData *ret = nil;
100  if (nil != user) {
101  ret = [user profile];
102  }
103  return ret;
104 }
GIDProfileData * profile
Definition: GIDGoogleUser.h:24
GIDGoogleUser * currentUser
Definition: GIDSignIn.h:100
GIDSignIn * sharedInstance()

◆ init()

- (id) init
implementation

Definition at line 18 of file Z5GoogleLoginController.m.

19 {
20  localLoginListeners = [[NSMutableArray alloc] initWithCapacity:10];
21  if (self) {
22  self.signInAttemptComplete = [NSNumber numberWithBool:NO];
23  }
24 
25  return self;
26 }

◆ logOutGoogle()

- (void) logOutGoogle

Definition at line 38 of file Z5GoogleLoginController.m.

39 {
40  NSLog(@"Z5GoogleLoginController.logOutGoogle: user: %@", _username);
41 
44 
45  _username = nil;
46  NSLog(@"Z5GoogleLoginController.logOutGoogle: done(user: %@)", _username);
47 }
void signOut()
void disconnect()
GIDSignIn * sharedInstance()

◆ removeLoginListener:()

- (void) removeLoginListener: (id<Z5GoogleLoginListener>)  ear

Definition at line 115 of file Z5GoogleLoginController.m.

115  : (id<Z5GoogleLoginListener>)ear
116 {
117  [localLoginListeners removeObject:ear];
118 }

◆ signedInUsername()

- (NSString *) signedInUsername

Definition at line 86 of file Z5GoogleLoginController.m.

86  {
87  NSString *ret;
89  if (nil==user) {
90  ret = nil;
91  } else {
92  ret = [[user profile] name];
93  }
94  return ret;
95 }
GIDProfileData * profile
Definition: GIDGoogleUser.h:24
GIDGoogleUser * currentUser
Definition: GIDSignIn.h:100
NSString * name
GIDSignIn * sharedInstance()

◆ signIn:didDisconnectWithUser:withError:()

- (void) signIn: (GIDSignIn *)  signIn
didDisconnectWithUser: (GIDGoogleUser *)  user
withError: (NSError *)  error 
implementation

Definition at line 74 of file Z5GoogleLoginController.m.

74  :(GIDSignIn *)signIn
75 didDisconnectWithUser:(GIDGoogleUser *)user
76  withError:(NSError *)error {
77  // Perform any operations when the user disconnects from app here.
78  NSLog(@"Z5GoogleLoginController.didDisconnectWithUser");
79  self.signedIn = [NSNumber numberWithBool:NO];
80  _username = nil;
81  for (id<Z5GoogleLoginListener>ear in localLoginListeners) {
82  [ear signedOut: _signedInUser];
83  }
84 }

◆ signIn:didSignInForUser:withError:()

- (void) signIn: (GIDSignIn *)  signIn
didSignInForUser: (GIDGoogleUser *)  user
withError: (NSError *)  error 
implementation

Definition at line 51 of file Z5GoogleLoginController.m.

51  :(GIDSignIn *)signIn
52 didSignInForUser:(GIDGoogleUser *)user
53  withError:(NSError *)error {
54 
55  if (nil == error) {
56  _signedInUser = user;
57  self.signedIn = [NSNumber numberWithBool:YES];
58 
59  NSString *fullName = user.profile.name;
60  _username = fullName;
61  NSLog(@"GoogleLoginController.didSignInForUser: %@", fullName);
62  self.signedIn = [NSNumber numberWithBool:YES];
63 
64  for (id<Z5GoogleLoginListener>ear in localLoginListeners) {
65  [ear signedIn: _signedInUser];
66  }
67  } else if (-4 == [error code]) {
68  NSLog(@"Z5GoogleLoginController.didSignInForUser: no one logged on");
69  } else {
70  NSLog(@"Z5GoogleLoginController.didSignInForUser: error: %ld", (long)[error code]);
71  }
72 }
GIDProfileData * profile
Definition: GIDGoogleUser.h:24
NSString * name

Property Documentation

◆ hostname

- (NSString*) hostname
readwritenonatomicstrong

Definition at line 22 of file Z5GoogleLoginController.h.

◆ password

- (NSString*) password
readwritenonatomicstrong

Definition at line 24 of file Z5GoogleLoginController.h.

◆ signedIn

- (NSNumber*) signedIn
readwritenonatomicstrong

Definition at line 18 of file Z5GoogleLoginController.h.

◆ signedInUser

- (GIDGoogleUser*) signedInUser
readwritenonatomicstrong

Definition at line 20 of file Z5GoogleLoginController.h.

◆ signInAttemptComplete

- (NSNumber*) signInAttemptComplete
readwritenonatomicstrong

Definition at line 19 of file Z5GoogleLoginController.h.

◆ username

- (NSString*) username
readwritenonatomicstrong

Definition at line 23 of file Z5GoogleLoginController.h.


The documentation for this class was generated from the following files: