@@ -151,6 +151,16 @@ - (BOOL)validateEmail:(NSString *)email {
151
151
152
152
}
153
153
154
+ - (NSString *)timeFormatted : (NSUInteger )totalSeconds {
155
+ NSDateFormatter *formatter = [[NSDateFormatter alloc ] init ];
156
+ [formatter setDateStyle: NSDateFormatterNoStyle];
157
+ [formatter setTimeStyle: NSDateFormatterMediumStyle];
158
+
159
+ NSDate *date = [NSDate dateWithTimeIntervalSinceNow: totalSeconds];
160
+
161
+ return [formatter stringFromDate: date];
162
+ }
163
+
154
164
#pragma mark - UIResponder
155
165
156
166
- (void )touchesBegan : (NSSet *)touches withEvent : (UIEvent *)event {
@@ -198,11 +208,15 @@ -(BOOL)textFieldShouldReturn:(UITextField *)textField {
198
208
#pragma mark - MEGARequestDelegate
199
209
200
210
- (void )onRequestStart : (MEGASdk *)api request : (MEGARequest *)request {
201
- [SVProgressHUD showWithMaskType: SVProgressHUDMaskTypeClear];
211
+ if ([request type ] == MEGARequestTypeLogin) {
212
+ [SVProgressHUD setDefaultMaskType: SVProgressHUDMaskTypeClear];
213
+ [SVProgressHUD show ];
214
+ }
202
215
}
203
216
204
217
- (void )onRequestFinish : (MEGASdk *)api request : (MEGARequest *)request error : (MEGAError *)error {
205
218
if ([error type ]) {
219
+ [SVProgressHUD setDefaultMaskType: SVProgressHUDMaskTypeNone];
206
220
[SVProgressHUD dismiss ];
207
221
switch ([error type ]) {
208
222
case MEGAErrorTypeApiEArgs:
@@ -218,6 +232,39 @@ - (void)onRequestFinish:(MEGASdk *)api request:(MEGARequest *)request error:(MEG
218
232
break ;
219
233
}
220
234
235
+ case MEGAErrorTypeApiETooMany: {
236
+ NSString *message = [NSString stringWithFormat: AMLocalizedString (@" tooManyAttemptsLogin" , @" Error message when to many attempts to login" ), [self timeFormatted: 3600 ]];
237
+ UIAlertView *alert = [[UIAlertView alloc ] initWithTitle: AMLocalizedString (@" error" , nil )
238
+ message: message
239
+ delegate: self
240
+ cancelButtonTitle: AMLocalizedString (@" ok" , nil )
241
+ otherButtonTitles: nil ];
242
+ [alert show ];
243
+
244
+ break ;
245
+ }
246
+
247
+ case MEGAErrorTypeApiEIncomplete: {
248
+ UIAlertView *alert = [[UIAlertView alloc ] initWithTitle: AMLocalizedString (@" error" , nil )
249
+ message: AMLocalizedString (@" accountNotValidated" , @" Error message when trying to login to an account not validated" )
250
+ delegate: self
251
+ cancelButtonTitle: AMLocalizedString (@" ok" , nil )
252
+ otherButtonTitles: nil ];
253
+ [alert show ];
254
+
255
+ break ;
256
+ }
257
+
258
+ case MEGAErrorTypeApiEBlocked: {
259
+ UIAlertView *alert = [[UIAlertView alloc ] initWithTitle: AMLocalizedString (@" error" , nil )
260
+ message: AMLocalizedString (@" accountBlocked" , @" Error message when trying to login and the account is suspended" )
261
+ delegate: self
262
+ cancelButtonTitle: AMLocalizedString (@" ok" , nil )
263
+ otherButtonTitles: nil ];
264
+ [alert show ];
265
+ break ;
266
+ }
267
+
221
268
default :
222
269
break ;
223
270
}
@@ -244,10 +291,4 @@ - (void)onRequestFinish:(MEGASdk *)api request:(MEGARequest *)request error:(MEG
244
291
}
245
292
}
246
293
247
- - (void )onRequestUpdate : (MEGASdk *)api request : (MEGARequest *)request {
248
- }
249
-
250
- - (void )onRequestTemporaryError : (MEGASdk *)api request : (MEGARequest *)request error : (MEGAError *)error {
251
- }
252
-
253
294
@end
0 commit comments