CCSettings.m 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939
  1. //
  2. // CCSettings.m
  3. // Crypto Cloud Technology Nextcloud
  4. //
  5. // Created by Marino Faggiana on 24/11/14.
  6. // Copyright (c) 2014 TWS. All rights reserved.
  7. //
  8. // Author Marino Faggiana <m.faggiana@twsweb.it>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. #import "CCSettings.h"
  24. #import "AppDelegate.h"
  25. #import "CCMain.h"
  26. #import "TableAccount+CoreDataClass.h"
  27. #define alertViewEsci 1
  28. #define alertViewAzzeraCache 2
  29. @implementation CCSettings
  30. - (id)initWithCoder:(NSCoder *)aDecoder
  31. {
  32. self = [super initWithCoder:aDecoder];
  33. if (self) {
  34. [self initializeForm];
  35. app.activeSettings = self;
  36. }
  37. return self;
  38. }
  39. - (void)initializeForm
  40. {
  41. XLFormDescriptor *form;
  42. XLFormSectionDescriptor *section;
  43. XLFormRowDescriptor *row;
  44. form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_settings_", nil)];
  45. form.rowNavigationOptions = XLFormRowNavigationOptionNone;
  46. // Section : PASSWORD --------------------------------------------------------------
  47. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_passcode_", nil)];
  48. [form addFormSection:section];
  49. // Passcode
  50. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"bloccopasscode" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_lock_not_active_", nil)];
  51. [row.cellConfig setObject:[UIImage imageNamed:image_settingsPasscodeNO] forKey:@"imageView.image"];
  52. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  53. [row.cellConfig setObject:COLOR_BRAND forKey:@"textLabel.textColor"];
  54. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  55. //[row.cellConfig setObject:@(UITableViewCellAccessoryDisclosureIndicator) forKey:@"accessoryType"];
  56. row.action.formSelector = @selector(bloccoPassword);
  57. [section addFormRow:row];
  58. // Passcode simply
  59. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"simplypasscode" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_lock_protection_simply_", nil)];
  60. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  61. [section addFormRow:row];
  62. // Passcode only directory
  63. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"onlylockdir" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_lock_protection_folder_", nil)];
  64. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  65. [section addFormRow:row];
  66. // Section : CLOUD ACCOUNT --------------------------------------------------------------
  67. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_cloud_account_", nil)];
  68. [form addFormSection:section];
  69. // version
  70. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"versionserver" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_version_server_", nil)];
  71. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  72. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  73. [section addFormRow:row];
  74. // Url
  75. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"urlcloud" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_url_", nil)];
  76. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  77. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  78. [section addFormRow:row];
  79. // username
  80. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"usernamecloud" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_username_", nil)];
  81. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  82. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  83. [section addFormRow:row];
  84. // information
  85. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"userinformation" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_information_", nil)];
  86. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  87. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  88. row.cellConfig[@"textLabel.numberOfLines"] = @0;
  89. [section addFormRow:row];
  90. // email
  91. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"useremail" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_email_", nil)];
  92. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  93. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  94. [section addFormRow:row];
  95. // quota
  96. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"quota" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_quota_", nil)];
  97. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  98. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  99. [section addFormRow:row];
  100. // Change Account
  101. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"changecredentials" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_change_credentials_", nil)];
  102. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  103. [row.cellConfig setObject:[UIImage imageNamed:image_settingsCredentials] forKey:@"imageView.image"];
  104. row.action.formSegueIdentifier = @"CCManageAccountSegue";
  105. [section addFormRow:row];
  106. // Section --------------------------------------------------------------
  107. section = [XLFormSectionDescriptor formSection];
  108. [form addFormSection:section];
  109. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"cameraupload" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_uploading_from_camera_", nil)];
  110. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  111. [row.cellConfig setObject:[UIImage imageNamed:image_settingsCameraUpload] forKey:@"imageView.image"];
  112. row.action.formSegueIdentifier = @"CCManageCameraUploadSegue";
  113. [section addFormRow:row];
  114. // Section --------------------------------------------------------------
  115. section = [XLFormSectionDescriptor formSection];
  116. [form addFormSection:section];
  117. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"optimizations" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_optimizations_", nil)];
  118. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  119. [row.cellConfig setObject:[UIImage imageNamed:image_settingsOptimizations] forKey:@"imageView.image"];
  120. row.action.formSegueIdentifier = @"CCManageOptimizationsSegue";
  121. [section addFormRow:row];
  122. // Section --------------------------------------------------------------
  123. section = [XLFormSectionDescriptor formSection];
  124. [form addFormSection:section];
  125. // Crypto Cloud
  126. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"cryptocloud" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_crypto_cloud_system_", nil)];
  127. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  128. [row.cellConfig setObject:[UIImage imageNamed:image_settingsCryptoCloud] forKey:@"imageView.image"];
  129. row.action.formSegueIdentifier = @"CCManageCryptoCloudSegue";
  130. [section addFormRow:row];
  131. // Section : INFORMATION --------------------------------------------------------------
  132. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_information_", nil)];
  133. [form addFormSection:section];
  134. section.footerTitle = @"Nextcloud © 2017 T.W.S. Inc.";
  135. // Acknowledgements
  136. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"buttonLeftAligned" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_acknowledgements_", nil)];
  137. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  138. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  139. [row.cellConfig setObject:COLOR_BRAND forKey:@"textLabel.textColor"];
  140. [row.cellConfig setObject:[UIImage imageNamed:image_settingsAcknowledgements] forKey:@"imageView.image"];
  141. row.action.formBlock = ^(XLFormRowDescriptor * sender){
  142. [self performSegueWithIdentifier:@"AcknowledgementsSegue" sender:sender];
  143. [self deselectFormRow:sender];
  144. };
  145. [section addFormRow:row];
  146. // Help
  147. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"help" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_help_", nil)];
  148. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  149. [row.cellConfig setObject:[UIImage imageNamed:image_settingsHelp] forKey:@"imageView.image"];
  150. row.action.formSegueIdentifier = @"CCManageHelpSegue";
  151. [section addFormRow:row];
  152. // Contact us mail
  153. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"sendmail" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_contact_by_email_", nil)];
  154. [row.cellConfig setObject:COLOR_BRAND forKey:@"textLabel.textColor"];
  155. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  156. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  157. [row.cellConfig setObject:[UIImage imageNamed:image_settingsMail] forKey:@"imageView.image"];
  158. row.action.formSelector = @selector(sendMail:);
  159. [section addFormRow:row];
  160. // Version
  161. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"versioneapplicazione" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_app_version_", nil)];
  162. row.value = [NSString stringWithFormat:@"%@ (%@)", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
  163. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  164. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  165. [section addFormRow:row];
  166. // Section --------------------------------------------------------------
  167. section = [XLFormSectionDescriptor formSection];
  168. [form addFormSection:section];
  169. // Clear cache
  170. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"azzeracache" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_clear_cache_no_size_", nil)];
  171. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  172. [row.cellConfig setObject:COLOR_BRAND forKey:@"textLabel.textColor"];
  173. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  174. [row.cellConfig setObject:[UIImage imageNamed:image_settingsClearCache] forKey:@"imageView.image"];
  175. row.action.formSelector = @selector(azzeraCache:);
  176. [section addFormRow:row];
  177. // Section --------------------------------------------------------------
  178. section = [XLFormSectionDescriptor formSection];
  179. [form addFormSection:section];
  180. // Exit
  181. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"esci" rowType:XLFormRowDescriptorTypeButton title:[CCUtility localizableBrand:@"_exit_" table:nil]];
  182. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  183. [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
  184. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  185. [row.cellConfig setObject:[UIImage imageNamed:image_settingsExit] forKey:@"imageView.image"];
  186. row.action.formSelector = @selector(esci:);
  187. [section addFormRow:row];
  188. #ifdef DEBUG
  189. /*
  190. // Section : debug
  191. section = [XLFormSectionDescriptor formSectionWithTitle:@"Debug"];
  192. [form addFormSection:section];
  193. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"adminRemoveVersion" rowType:XLFormRowDescriptorTypeButton title:@"Remove Version"];
  194. [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
  195. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  196. [row.cellConfig setObject:[UIImage imageNamed:image_settingsAdmin] forKey:@"imageView.image"];
  197. row.action.formSelector = @selector(adminRemoveVersion:);
  198. [section addFormRow:row];
  199. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"quickActionPhotos" rowType:XLFormRowDescriptorTypeButton title:@"Quick Action Photos"];
  200. [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
  201. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  202. [row.cellConfig setObject:[UIImage imageNamed:image_settingsAdmin] forKey:@"imageView.image"];
  203. row.action.formSelector = @selector(quickActionPhotos:);
  204. [section addFormRow:row];
  205. */
  206. #endif
  207. self.form = form;
  208. }
  209. - (void)viewDidLoad
  210. {
  211. [super viewDidLoad];
  212. self.hud = [[CCHud alloc] initWithView:[[[UIApplication sharedApplication] delegate] window]];
  213. self.title = NSLocalizedString(@"_settings_", nil);
  214. // Color
  215. [CCAspect aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
  216. [CCAspect aspectTabBar:self.tabBarController.tabBar hidden:NO];
  217. }
  218. // Apparirà
  219. - (void)viewWillAppear:(BOOL)animated
  220. {
  221. [super viewWillAppear:animated];
  222. // Color
  223. [CCAspect aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
  224. [CCAspect aspectTabBar:self.tabBarController.tabBar hidden:NO];
  225. [self reloadForm];
  226. }
  227. // E' apparsa
  228. - (void)viewDidAppear:(BOOL)animated
  229. {
  230. [super viewDidAppear:animated];
  231. }
  232. #pragma --------------------------------------------------------------------------------------------
  233. #pragma mark === Admin ===
  234. #pragma --------------------------------------------------------------------------------------------
  235. /*
  236. - (void)adminRemoveVersion:(XLFormRowDescriptor *)sender
  237. {
  238. [self deselectFormRow:sender];
  239. [CCUtility adminRemoveVersion];
  240. exit(0);
  241. }
  242. - (void)quickActionPhotos:(XLFormRowDescriptor *)sender
  243. {
  244. NSString *bundleId = [NSBundle mainBundle].bundleIdentifier;
  245. UIApplicationShortcutItem *shortcutPhotos = [[UIApplicationShortcutItem alloc] initWithType:[NSString stringWithFormat:@"%@.photos", bundleId] localizedTitle:@"" localizedSubtitle:nil icon:nil userInfo:nil];
  246. [app handleShortCutItem:shortcutPhotos];
  247. }
  248. */
  249. #pragma --------------------------------------------------------------------------------------------
  250. #pragma mark === Chiamate dal Form ===
  251. #pragma --------------------------------------------------------------------------------------------
  252. - (void)reloadForm
  253. {
  254. self.form.delegate = nil;
  255. // ----------------------
  256. XLFormRowDescriptor *rowBloccoPasscode = [self.form formRowWithTag:@"bloccopasscode"];
  257. XLFormRowDescriptor *rowSimplyPasscode = [self.form formRowWithTag:@"simplypasscode"];
  258. XLFormRowDescriptor *rowOnlyLockDir = [self.form formRowWithTag:@"onlylockdir"];
  259. XLFormRowDescriptor *rowVersionServer = [self.form formRowWithTag:@"versionserver"];
  260. XLFormRowDescriptor *rowUrlCloud = [self.form formRowWithTag:@"urlcloud"];
  261. XLFormRowDescriptor *rowUserNameCloud = [self.form formRowWithTag:@"usernamecloud"];
  262. XLFormRowDescriptor *rowUserInformation = [self.form formRowWithTag:@"userinformation"];
  263. XLFormRowDescriptor *rowUserEmail = [self.form formRowWithTag:@"useremail"];
  264. XLFormRowDescriptor *rowQuota = [self.form formRowWithTag:@"quota"];
  265. //XLFormRowDescriptor *rowChangeCredentials = [self.form formRowWithTag:@"changecredentials"];
  266. // ------------------------------------------------------------------
  267. if ([[CCUtility getBlockCode] length]) {
  268. rowBloccoPasscode.title = NSLocalizedString(@"_lock_active_", nil);
  269. [rowBloccoPasscode.cellConfig setObject:[UIImage imageNamed:image_settingsPasscodeYES] forKey:@"imageView.image"];
  270. } else {
  271. rowBloccoPasscode.title = NSLocalizedString(@"_lock_not_active_", nil);
  272. [rowBloccoPasscode.cellConfig setObject:[UIImage imageNamed:image_settingsPasscodeNO] forKey:@"imageView.image"];
  273. }
  274. if ([CCUtility getSimplyBlockCode]) [rowSimplyPasscode setValue:@1]; else [rowSimplyPasscode setValue:@0];
  275. if ([CCUtility getOnlyLockDir]) [rowOnlyLockDir setValue:@1]; else [rowOnlyLockDir setValue:@0];
  276. // Avatar
  277. UIImage *avatar = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/avatar.png", app.directoryUser]];
  278. if (avatar) {
  279. avatar = [CCGraphics scaleImage:avatar toSize:CGSizeMake(50, 50)];
  280. APAvatarImageView *avatarImageView = [[APAvatarImageView alloc] initWithImage:avatar borderColor:[UIColor lightGrayColor] borderWidth:0.5];
  281. CGSize imageSize = avatarImageView.bounds.size;
  282. UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);
  283. CGContextRef context = UIGraphicsGetCurrentContext();
  284. [avatarImageView.layer renderInContext:context];
  285. avatar = UIGraphicsGetImageFromCurrentImageContext();
  286. UIGraphicsEndImageContext();
  287. }
  288. TableAccount *tableAccount = [CCCoreData getActiveAccount];
  289. rowVersionServer.value = [CCNetworking sharedNetworking].sharedOCCommunication.getCurrentServerVersion;
  290. rowUrlCloud.value = app.activeUrl;
  291. rowUserNameCloud.value = app.activeUser;
  292. if (avatar || tableAccount.displayName.length > 0 || tableAccount.address.length > 0 || tableAccount.phone.length > 0) {
  293. rowUserInformation.title = [NSString stringWithFormat:@"%@ %@ %@", tableAccount.displayName, tableAccount.address, tableAccount.phone];
  294. rowUserInformation.disabled = @YES;
  295. if (avatar)
  296. [rowUserInformation.cellConfig setObject:avatar forKey:@"imageView.image"];
  297. else
  298. [rowUserInformation.cellConfig setObject:[UIImage imageNamed:image_avatar] forKey:@"imageView.image"];
  299. } else {
  300. rowUserInformation.title = NSLocalizedString(@"_information_", nil);
  301. rowUserInformation.disabled = @NO;
  302. [rowUserInformation.cellConfig setObject:[UIImage imageNamed:image_avatar] forKey:@"imageView.image"];
  303. }
  304. rowUserEmail.value = tableAccount.email;
  305. NSString *quota = [CCUtility transformedSize:[tableAccount.quotaTotal doubleValue]];
  306. NSString *quotaAvailable = [CCUtility transformedSize:[tableAccount.quotaFree doubleValue]];
  307. rowQuota.value = [NSString stringWithFormat:@"%@ / %@ %@", quota, quotaAvailable, NSLocalizedString(@"_available_", nil)];
  308. // -----------------------------------------------------------------
  309. [self.tableView reloadData];
  310. self.form.delegate = self;
  311. }
  312. - (void)recalculateSize
  313. {
  314. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  315. self.form.delegate = nil;
  316. XLFormRowDescriptor *rowAzzeraCache = [self.form formRowWithTag:@"azzeracache"];
  317. //NSString *size = [CCUtility transformedSize:[[self getUserDirectorySize] longValue]];
  318. //rowAzzeraCache.title = [NSString stringWithFormat:NSLocalizedString(@"_clear_cache_", nil), size];
  319. rowAzzeraCache.title = NSLocalizedString(@"_clear_cache_no_size_", nil);
  320. [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
  321. self.form.delegate = self;
  322. });
  323. }
  324. - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  325. {
  326. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  327. if ([rowDescriptor.tag isEqualToString:@"onlylockdir"]) {
  328. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  329. [CCUtility setOnlyLockDir:true];
  330. } else {
  331. [CCUtility setOnlyLockDir:false];
  332. }
  333. }
  334. if ([rowDescriptor.tag isEqualToString:@"simplypasscode"]) {
  335. if ([[CCUtility getBlockCode] length] == 0)
  336. [CCUtility setSimplyBlockCode:[[rowDescriptor.value valueData] boolValue]];
  337. else
  338. [self changeSimplyPassword];
  339. }
  340. }
  341. - (void)checkEncryptPass:(XLFormRowDescriptor *)sender
  342. {
  343. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  344. viewController.delegate = self;
  345. viewController.fromType = CCBKPasscodeFromCheckCryptoKey;
  346. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  347. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  348. viewController.passcodeInputView.maximumLength = 64;
  349. viewController.title = NSLocalizedString(@"_check_key_aes_256_", nil);
  350. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  351. viewController.navigationItem.leftBarButtonItem.tintColor = COLOR_CRYPTOCLOUD;
  352. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  353. [self presentViewController:navigationController animated:YES completion:nil];
  354. }
  355. - (void)changeSimplyPassword
  356. {
  357. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  358. viewController.delegate = self;
  359. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  360. viewController.fromType = CCBKPasscodeFromSimply;
  361. viewController.title = NSLocalizedString(@"_change_simply_passcode_", nil);
  362. viewController.inputViewTitlePassword = YES;
  363. if ([CCUtility getSimplyBlockCode]) {
  364. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  365. viewController.passcodeInputView.maximumLength = 6;
  366. } else {
  367. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  368. viewController.passcodeInputView.maximumLength = 64;
  369. }
  370. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:BKPasscodeKeychainServiceName];
  371. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  372. viewController.touchIDManager = touchIDManager;
  373. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  374. viewController.navigationItem.leftBarButtonItem.tintColor = COLOR_CRYPTOCLOUD;
  375. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  376. [self presentViewController:navigationController animated:YES completion:nil];
  377. }
  378. - (void)bloccoPassword
  379. {
  380. // ATTIVAZIONE LOCK PASSWORD
  381. if ([[CCUtility getBlockCode] length] == 0) {
  382. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  383. viewController.delegate = self;
  384. viewController.type = BKPasscodeViewControllerNewPasscodeType;
  385. viewController.fromType = CCBKPasscodeFromSettingsPasscode;
  386. viewController.inputViewTitlePassword = YES;
  387. if ([CCUtility getSimplyBlockCode]) {
  388. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  389. viewController.passcodeInputView.maximumLength = 6;
  390. } else {
  391. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  392. viewController.passcodeInputView.maximumLength = 64;
  393. }
  394. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:BKPasscodeKeychainServiceName];
  395. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  396. viewController.touchIDManager = touchIDManager;
  397. viewController.title = NSLocalizedString(@"_passcode_activate_", nil);
  398. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  399. viewController.navigationItem.leftBarButtonItem.tintColor = COLOR_CRYPTOCLOUD;
  400. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  401. [self presentViewController:navigationController animated:YES completion:nil];
  402. } else {
  403. // OFF LOCK PASSWORD
  404. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  405. viewController.delegate = self;
  406. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  407. viewController.fromType = CCBKPasscodeFromSettingsPasscode;
  408. viewController.inputViewTitlePassword = YES;
  409. if ([CCUtility getSimplyBlockCode]) {
  410. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  411. viewController.passcodeInputView.maximumLength = 6;
  412. } else {
  413. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  414. viewController.passcodeInputView.maximumLength = 64;
  415. }
  416. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:BKPasscodeKeychainServiceName];
  417. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  418. viewController.touchIDManager = touchIDManager;
  419. viewController.title = NSLocalizedString(@"_disabling_passcode_", nil);
  420. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  421. viewController.navigationItem.leftBarButtonItem.tintColor = COLOR_CRYPTOCLOUD;
  422. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  423. [self presentViewController:navigationController animated:YES completion:nil];
  424. }
  425. }
  426. - (void)esci:(XLFormRowDescriptor *)sender
  427. {
  428. [self deselectFormRow:sender];
  429. UIAlertView * alertView =[[UIAlertView alloc ] initWithTitle:[CCUtility localizableBrand:@"_exit_" table:nil]
  430. message:[CCUtility localizableBrand:@"_want_exit_" table:nil]
  431. delegate:self
  432. cancelButtonTitle:NSLocalizedString(@"_cancel_", nil)
  433. otherButtonTitles: nil];
  434. alertView.tag = alertViewEsci;
  435. [alertView addButtonWithTitle:NSLocalizedString(@"_proceed_", nil)];
  436. [alertView show];
  437. }
  438. - (void)azzeraCache:(XLFormRowDescriptor *)sender
  439. {
  440. [self deselectFormRow:sender];
  441. UIAlertView * alertView =[[UIAlertView alloc ] initWithTitle:NSLocalizedString(@"_delete_cache_",nil)
  442. message:NSLocalizedString(@"_want_delete_cache_", nil)
  443. delegate:self
  444. cancelButtonTitle:NSLocalizedString(@"_cancel_", nil)
  445. otherButtonTitles: nil];
  446. alertView.tag = alertViewAzzeraCache;
  447. [alertView addButtonWithTitle:NSLocalizedString(@"_proceed_", nil)];
  448. [alertView show];
  449. }
  450. #pragma --------------------------------------------------------------------------------------------
  451. #pragma mark === Mail ===
  452. #pragma --------------------------------------------------------------------------------------------
  453. - (void) mailComposeController:(MFMailComposeViewController *)vc didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
  454. {
  455. switch (result)
  456. {
  457. case MFMailComposeResultCancelled:
  458. [app messageNotification:@"_info_" description:@"_mail_deleted_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
  459. break;
  460. case MFMailComposeResultSaved:
  461. [app messageNotification:@"_info_" description:@"_mail_saved_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
  462. break;
  463. case MFMailComposeResultSent:
  464. [app messageNotification:@"_info_" description:@"_mail_sent_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
  465. break;
  466. case MFMailComposeResultFailed: {
  467. NSString *msg = [NSString stringWithFormat:NSLocalizedString(@"_mail_failure_", nil), [error localizedDescription]];
  468. [app messageNotification:@"_error_" description:msg visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError];
  469. }
  470. break;
  471. default:
  472. break;
  473. }
  474. // Close the Mail Interface
  475. [self dismissViewControllerAnimated:YES completion:NULL];
  476. }
  477. - (void)sendMail:(XLFormRowDescriptor *)sender
  478. {
  479. // Email Subject
  480. NSString *emailTitle = NSLocalizedString(@"_information_req_", nil);
  481. // Email Content
  482. NSString *messageBody;
  483. // Email Recipents
  484. NSArray *toRecipents;
  485. messageBody = [NSString stringWithFormat:@"\n\n\nNextcloud Version %@ (%@)", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
  486. toRecipents = [NSArray arrayWithObject:_mail_me_];
  487. MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
  488. mc.mailComposeDelegate = self;
  489. [mc setSubject:emailTitle];
  490. [mc setMessageBody:messageBody isHTML:NO];
  491. [mc setToRecipients:toRecipents];
  492. // Present mail view controller on screen
  493. [self presentViewController:mc animated:YES completion:NULL];
  494. }
  495. - (void)sendMailEncryptPass
  496. {
  497. [CCUtility sendMailEncryptPass:[CCUtility getEmail] validateEmail:NO form:self];
  498. }
  499. #pragma --------------------------------------------------------------------------------------------
  500. #pragma mark === AlertView ===
  501. #pragma --------------------------------------------------------------------------------------------
  502. - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
  503. {
  504. // Remove ALL
  505. if (buttonIndex == 1 && alertView.tag == alertViewEsci)
  506. {
  507. [self.hud visibleIndeterminateHud];
  508. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  509. [app cancelAllOperations];
  510. [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
  511. [[NSURLCache sharedURLCache] setMemoryCapacity:0];
  512. [[NSURLCache sharedURLCache] setDiskCapacity:0];
  513. [[CCNetworking sharedNetworking] invalidateAndCancelAllSession];
  514. [CCCoreData flushAllDatabase];
  515. [CCUtility deleteAllChainStore];
  516. [self emptyDocumentsDirectory];
  517. [self emptyLibraryDirectory];
  518. [self emptyGroupApplicationSupport];
  519. NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
  520. for (NSString *file in tmpDirectory)
  521. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
  522. [self.hud hideHud];
  523. exit(0);
  524. });
  525. }
  526. // Clear Cache
  527. if (buttonIndex == 1 && alertView.tag == alertViewAzzeraCache)
  528. {
  529. [self.hud visibleHudTitle:NSLocalizedString(@"_remove_cache_", nil) mode:MBProgressHUDModeIndeterminate color:nil];
  530. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  531. [app cancelAllOperations];
  532. [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
  533. [[NSURLCache sharedURLCache] setMemoryCapacity:0];
  534. [[NSURLCache sharedURLCache] setDiskCapacity:0];
  535. [CCCoreData flushTableAutomaticUploadAccount:app.activeAccount selector:nil];
  536. [CCCoreData flushTableDirectoryAccount:app.activeAccount];
  537. [CCCoreData flushTableLocalFileAccount:app.activeAccount];
  538. [CCCoreData flushTableMetadataAccount:app.activeAccount];
  539. [self emptyUserDirectoryUser:app.activeUser url:app.activeUrl];
  540. [self emptyLocalDirectory];
  541. NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
  542. for (NSString *file in tmpDirectory)
  543. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
  544. [self recalculateSize];
  545. // Inizialized home
  546. [[NSNotificationCenter defaultCenter] postNotificationName:@"initializeMain" object:nil];
  547. [self.hud hideHud];
  548. });
  549. }
  550. }
  551. #pragma --------------------------------------------------------------------------------------------
  552. #pragma mark === BKPasscodeViewController ===
  553. #pragma --------------------------------------------------------------------------------------------
  554. - (void)passcodeViewController:(CCBKPasscode *)aViewController didFinishWithPasscode:(NSString *)aPasscode
  555. {
  556. [aViewController dismissViewControllerAnimated:YES completion:nil];
  557. switch (aViewController.type) {
  558. case BKPasscodeViewControllerNewPasscodeType: {
  559. // enable passcode
  560. [CCUtility setBlockCode:aPasscode];
  561. }
  562. break;
  563. case BKPasscodeViewControllerCheckPasscodeType: {
  564. // disable passcode
  565. if (aViewController.fromType == CCBKPasscodeFromSettingsPasscode) {
  566. [CCUtility setBlockCode:@""];
  567. [CCCoreData setAllDirectoryUnLockForAccount:app.activeAccount];
  568. [app.activeMain.tableView reloadData];
  569. }
  570. // email Key EAS-256
  571. if (aViewController.fromType == CCBKPasscodeFromCheckCryptoKey)
  572. [self sendMailEncryptPass];
  573. // change simply
  574. if (aViewController.fromType == CCBKPasscodeFromSimply) {
  575. // disable passcode
  576. [CCUtility setBlockCode:@""];
  577. [CCCoreData setAllDirectoryUnLockForAccount:app.activeAccount];
  578. [app.activeMain.tableView reloadData];
  579. [CCUtility setSimplyBlockCode:![CCUtility getSimplyBlockCode]];
  580. // Call new passcode
  581. [self bloccoPassword];
  582. }
  583. }
  584. break;
  585. default:
  586. break;
  587. }
  588. [self reloadForm];
  589. }
  590. - (void)passcodeViewController:(CCBKPasscode *)aViewController authenticatePasscode:(NSString *)aPasscode resultHandler:(void (^)(BOOL))aResultHandler
  591. {
  592. if (aViewController.fromType == CCBKPasscodeFromCheckCryptoKey) {
  593. NSString *key = [CCUtility getKeyChainPasscodeForUUID:[CCUtility getUUID]];
  594. if ([aPasscode isEqualToString:key]) {
  595. self.lockUntilDate = nil;
  596. self.failedAttempts = 0;
  597. aResultHandler(YES);
  598. } else aResultHandler(NO);
  599. }
  600. if (aViewController.fromType == CCBKPasscodeFromSettingsPasscode || aViewController.fromType == CCBKPasscodeFromSimply) {
  601. if ([aPasscode isEqualToString:[CCUtility getBlockCode]]) {
  602. self.lockUntilDate = nil;
  603. self.failedAttempts = 0;
  604. aResultHandler(YES);
  605. } else aResultHandler(NO);
  606. }
  607. }
  608. - (void)passcodeViewControllerDidFailAttempt:(CCBKPasscode *)aViewController
  609. {
  610. self.failedAttempts++;
  611. if (self.failedAttempts > 5) {
  612. NSTimeInterval timeInterval = 60;
  613. if (self.failedAttempts > 6) {
  614. NSUInteger multiplier = self.failedAttempts - 6;
  615. timeInterval = (5 * 60) * multiplier;
  616. if (timeInterval > 3600 * 24) {
  617. timeInterval = 3600 * 24;
  618. }
  619. }
  620. self.lockUntilDate = [NSDate dateWithTimeIntervalSinceNow:timeInterval];
  621. }
  622. }
  623. - (NSUInteger)passcodeViewControllerNumberOfFailedAttempts:(CCBKPasscode *)aViewController
  624. {
  625. return self.failedAttempts;
  626. }
  627. - (NSDate *)passcodeViewControllerLockUntilDate:(CCBKPasscode *)aViewController
  628. {
  629. return self.lockUntilDate;
  630. }
  631. - (void)passcodeViewCloseButtonPressed:(id)sender
  632. {
  633. [self dismissViewControllerAnimated:YES completion:nil];
  634. }
  635. #pragma --------------------------------------------------------------------------------------------
  636. #pragma mark == Utility ==
  637. #pragma --------------------------------------------------------------------------------------------
  638. - (void)emptyGroupApplicationSupport
  639. {
  640. NSString *file;
  641. NSURL *dirGroup = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:k_capabilitiesGroups];
  642. NSString *dirIniziale = [[dirGroup URLByAppendingPathComponent:appApplicationSupport] path];
  643. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  644. while (file = [enumerator nextObject])
  645. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  646. }
  647. - (void)emptyLibraryDirectory
  648. {
  649. NSString *file;
  650. NSString *dirIniziale;
  651. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
  652. dirIniziale = [paths objectAtIndex:0];
  653. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  654. while (file = [enumerator nextObject])
  655. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  656. }
  657. - (void)emptyDocumentsDirectory
  658. {
  659. NSString *file;
  660. NSString *dirIniziale;
  661. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  662. dirIniziale = [paths objectAtIndex:0];
  663. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  664. while (file = [enumerator nextObject])
  665. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  666. }
  667. - (void)emptyUserDirectoryUser:(NSString *)user url:(NSString *)url
  668. {
  669. NSString *file;
  670. NSString *dirIniziale;
  671. dirIniziale = [CCUtility getDirectoryActiveUser:user activeUrl:url];
  672. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  673. while (file = [enumerator nextObject]) {
  674. NSString *ext = [[file pathExtension] lowercaseString];
  675. // Do not remove ICO
  676. if ([ext isEqualToString:@"ico"])
  677. continue;
  678. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  679. }
  680. }
  681. - (void)emptyLocalDirectory
  682. {
  683. NSString *file;
  684. NSString *dirIniziale;
  685. dirIniziale = [CCUtility getDirectoryLocal];
  686. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  687. while (file = [enumerator nextObject])
  688. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  689. }
  690. - (NSNumber *)getUserDirectorySize
  691. {
  692. NSString *directoryUser = [CCUtility getDirectoryActiveUser:app.activeUser activeUrl:app.activeUrl];
  693. NSURL *directoryURL = [NSURL fileURLWithPath:directoryUser];
  694. unsigned long long count = 0;
  695. NSNumber *value = nil;
  696. if (! directoryURL) return 0;
  697. // Get dimension Document
  698. for (NSURL *url in [[NSFileManager defaultManager] enumeratorAtURL:directoryURL includingPropertiesForKeys:@[NSURLFileSizeKey] options:0 errorHandler:NULL]) {
  699. if ([url getResourceValue:&value forKey:NSURLFileSizeKey error:nil]) {
  700. count += [value longLongValue];
  701. } else {
  702. return nil;
  703. }
  704. }
  705. return @(count);
  706. }
  707. @end