KMVerificationWindowController.m 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083
  1. //
  2. // KMVerificationWindowController.m
  3. // PDF Reader Pro Edition
  4. //
  5. // Created by 王帅 on 2018/5/8.
  6. //
  7. #import "KMVerificationWindowController.h"
  8. #import "KMVerificationViewController.h"
  9. #import "KMVerificationActivateViewController.h"
  10. #import "KMVerificationExpiredViewController.h"
  11. #import "KMVerificationTrialViewController.h"
  12. #import "KMVerificationAlertViewController.h"
  13. #import "KMActivityALertViewController.h"
  14. #import "KMVerificationInfoViewController.h"
  15. #import "VerificationManager.h"
  16. //#import "KMMailHelper.h"
  17. #import "GBDeviceInfo.h"
  18. #import "Reachability.h"
  19. //#import "SKInspectPublicTool.h"
  20. //#import "FMTrackEventManager.h"
  21. #import "KMRepeatTrialAlertController.h"
  22. #import "KMRepeatVerifyExpireController.h"
  23. #import <PDF_Reader_Pro-Swift.h>
  24. #import "NSObject+DeviceInfo.h"
  25. @interface KMVerificationWindowController ()
  26. @property (nonatomic, assign) KMVerificationType type;
  27. @property (nonatomic, assign) IBOutlet NSBox *box;
  28. @property (nonatomic, assign) IBOutlet NSProgressIndicator *progressIndicator;
  29. @property (nonatomic, retain) KMVerificationViewController *normalViewController;
  30. @property (nonatomic, retain) KMVerificationActivateViewController *activateViewController;
  31. @property (nonatomic, retain) KMVerificationExpiredViewController *expiredViewController;
  32. @property (nonatomic, retain) KMVerificationTrialViewController *trialViewController;
  33. @property (nonatomic, retain) KMVerificationAlertViewController *alertViewController;
  34. @property (nonatomic, retain) KMActivityALertViewController *activityAlertViewController;
  35. @property (nonatomic, retain) KMVerificationInfoViewController *infoViewController;
  36. @property (nonatomic, retain) KMRepeatTrialAlertController *repeatTrialAlertController;//二次试用提示弹窗
  37. @property (nonatomic, retain) KMRepeatVerifyExpireController *repeatTrialExpireController;//二次试用过期弹窗
  38. @property (nonatomic, retain) KMTrialSuccessController *trialSuccessController;
  39. @property (nonatomic, retain) KMUnbindAlertViewController *unbindAlertController;
  40. @end
  41. @implementation KMVerificationWindowController
  42. + (void)launching {
  43. [VerificationManager manager];
  44. }
  45. + (BOOL)allowsShowExpired {
  46. #if VERSION_DMG
  47. if ([VerificationManager manager].status == ActivityStatusTrialExpire &&
  48. [VerificationManager manager].secondTrialEnabled == NO) {
  49. if (![[NSUserDefaults standardUserDefaults] objectForKey:@"allowTrialExpireShowKeyDMG"]) {
  50. [[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"allowTrialExpireShowKeyDMG"];
  51. return YES;
  52. }
  53. }
  54. return NO;
  55. #else
  56. NSDate *lastTimeDate = [[NSUserDefaults standardUserDefaults] objectForKey:@"kVerificationExpiredShowLastTimeDateKay"];
  57. if (lastTimeDate) {
  58. NSDate *date = [NSDate date];
  59. NSTimeInterval time = [date timeIntervalSinceDate:lastTimeDate];
  60. int days = ((int)time)/(3600*24);
  61. if (days < 15) {
  62. return NO;
  63. }
  64. }
  65. #endif
  66. return YES;
  67. }
  68. + (void)showExpiredInfo {
  69. if (ActivityStatusTrialExpire == [VerificationManager manager].status) {
  70. if ([KMVerificationWindowController allowsShowExpired]) {
  71. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeTrialExpired];
  72. [vc showWindow:nil];
  73. [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:@"kVerificationExpiredShowLastTimeDateKay"];
  74. [[NSUserDefaults standardUserDefaults] synchronize];
  75. }
  76. } else if (ActivityStatusVerifExpire == [VerificationManager manager].status) {
  77. if ([KMVerificationWindowController allowsShowExpired]) {
  78. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivateExpired];
  79. [vc showWindow:nil];
  80. [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:@"kVerificationExpiredShowLastTimeDateKay"];
  81. [[NSUserDefaults standardUserDefaults] synchronize];
  82. }
  83. }
  84. }
  85. + (BOOL)allowRepeatTrialAlertShow {
  86. //是否在开启APP时弹出二次试用弹窗提示框
  87. if ([VerificationManager manager].secondTrialEnabled) {
  88. if (![[NSUserDefaults standardUserDefaults] objectForKey:@"allowRepeatTrialAlertShowKey"]) {
  89. return YES;
  90. }
  91. }
  92. return NO;
  93. }
  94. + (BOOL)allowRepeatTrialExpireShow {
  95. if ([VerificationManager manager].status == ActivityStatusTrialExpire &&
  96. [VerificationManager manager].trialTimes == 2) {
  97. if (![[NSUserDefaults standardUserDefaults] objectForKey:@"allowRepeatTrialExpireShowKey"]) {
  98. return YES;
  99. }
  100. }
  101. return NO;
  102. }
  103. static KMVerificationWindowController *_currentWindowController = nil;
  104. + (KMVerificationWindowController *)verificationWithType:(KMVerificationType)type {
  105. if (_currentWindowController) {
  106. if (type != _currentWindowController.type) {
  107. [_currentWindowController close];
  108. } else {
  109. return _currentWindowController;
  110. }
  111. }
  112. KMVerificationWindowController *vc = [[KMVerificationWindowController alloc] initWithType:type];
  113. return vc;
  114. }
  115. #pragma mark Init Methods
  116. - (instancetype)initWithType:(KMVerificationType)type {
  117. if (self = [super initWithWindowNibName:@"KMVerificationWindowController"]) {
  118. _type = type;
  119. }
  120. return self;
  121. }
  122. - (void)dealloc {
  123. [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
  124. }
  125. #pragma mark - Getter Methods
  126. - (KMVerificationViewController *)normalViewController {
  127. if (!_normalViewController) {
  128. __block __typeof(self) blockSelf = self;
  129. _normalViewController = [[KMVerificationViewController alloc] init];
  130. _normalViewController.callback = ^(NSInteger index) {
  131. if (index == 0) {
  132. [blockSelf setContentView:blockSelf.activateViewController.view];
  133. } else if (index == 1) {
  134. if (KMVerificationTypeActivateExpired == self.type) {
  135. [blockSelf verificationFeedback];
  136. } else {
  137. [blockSelf close];
  138. }
  139. } else {
  140. [blockSelf verificationBuy];
  141. }
  142. };
  143. if (KMVerificationTypeTrialExpired == self.type) {
  144. _normalViewController.titleText = NSLocalizedString(@"Thank you for trying PDFull", nil);
  145. _normalViewController.messageText = NSLocalizedString(@"Your trial has expired. Buy Full version to annotate and edit PDF files.", nil);
  146. } else {
  147. _normalViewController.titleText = NSLocalizedString(@"PDFull Activation", nil);
  148. _normalViewController.messageText = NSLocalizedString(@"Buy Full Version to annotate and edit your PDF documents.", nil);
  149. }
  150. }
  151. return _normalViewController;
  152. }
  153. - (KMVerificationActivateViewController *)activateViewController {
  154. if (!_activateViewController) {
  155. __block __typeof(self) blockSelf = self;
  156. _activateViewController = [[KMVerificationActivateViewController alloc] init];
  157. _activateViewController.callback = ^(NSInteger index, NSString *string) {
  158. if (index == 0) {
  159. if (blockSelf.callback) {
  160. blockSelf.callback();
  161. blockSelf.callback = nil;
  162. [blockSelf close];
  163. } else {
  164. if (KMVerificationTypeTrial == blockSelf.type) {
  165. [blockSelf setContentView:blockSelf.trialViewController.view];
  166. } else if (KMVerificationTypeActivateExpired == blockSelf.type) {
  167. [blockSelf setContentView:blockSelf.expiredViewController.view];
  168. } else {
  169. [blockSelf setContentView:blockSelf.normalViewController.view];
  170. }
  171. }
  172. } else {
  173. // if (blockSelf.type == KMVerificationTypeActivateAIInfo) {
  174. // [blockSelf verificationActivateAIInfo:string];
  175. // } else {
  176. [blockSelf verificationActivate:string];
  177. // }
  178. }
  179. };
  180. if (self.type == KMVerificationTypeActivateAIInfo) {
  181. _activateViewController.type = self.type;
  182. }
  183. }
  184. return _activateViewController;
  185. }
  186. - (KMVerificationExpiredViewController *)expiredViewController {
  187. if (!_expiredViewController) {
  188. __block __typeof(self) blockSelf = self;
  189. _expiredViewController = [[KMVerificationExpiredViewController alloc] init];
  190. _expiredViewController.callback = ^(NSInteger index) {
  191. if (index == 0) {
  192. [blockSelf setContentView:blockSelf.activateViewController.view];
  193. } else {
  194. [blockSelf verificationFeedback];
  195. }
  196. };
  197. }
  198. return _expiredViewController;
  199. }
  200. - (KMVerificationTrialViewController *)trialViewController {
  201. if (!_trialViewController) {
  202. __block __typeof(self) blockSelf = self;
  203. _trialViewController = [[KMVerificationTrialViewController alloc] init];
  204. _trialViewController.callback = ^(NSInteger index, NSString *email, NSString *name) {
  205. if (index == 0) {
  206. [blockSelf setContentView:blockSelf.activateViewController.view];
  207. } else {
  208. [blockSelf verificationTrialForEmail:email name:name];
  209. }
  210. };
  211. }
  212. return _trialViewController;
  213. }
  214. - (KMVerificationAlertViewController *)alertViewController {
  215. if (!_alertViewController) {
  216. __block __typeof(self) blockSelf = self;
  217. _alertViewController = [[KMVerificationAlertViewController alloc] init];
  218. _alertViewController.callback = ^{
  219. [blockSelf close];
  220. };
  221. _alertViewController.buyActionHandle = ^{
  222. #if VERSION_DMG
  223. NSURL *url = [NSURL URLWithString:@"https://www.anyrecover.com/buy-pdf-editor-reader-converter"];
  224. [[NSWorkspace sharedWorkspace] openURL:url];
  225. #endif
  226. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"Btn_PUW_BuyNow-Trial"}];
  227. [blockSelf close];
  228. };
  229. }
  230. return _alertViewController;
  231. }
  232. - (KMActivityALertViewController *)activityAlertViewController {
  233. if (!_activityAlertViewController) {
  234. __block __typeof(self) blockSelf = self;
  235. _activityAlertViewController = [[KMActivityALertViewController alloc] init];
  236. _activityAlertViewController.callback = ^{
  237. [blockSelf close];
  238. };
  239. }
  240. return _activityAlertViewController;
  241. }
  242. - (KMVerificationInfoViewController *)infoViewController {
  243. if (!_infoViewController) {
  244. __weak __typeof(self) blockSelf = self;
  245. _infoViewController = [[KMVerificationInfoViewController alloc] init];
  246. _infoViewController.callback = ^{
  247. [blockSelf close];
  248. };
  249. _infoViewController.unbindAction = ^{
  250. dispatch_async(dispatch_get_main_queue(), ^{
  251. //输入序列码
  252. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeUnbindAlert];
  253. vc.callback = ^{
  254. };
  255. [vc showWindow:nil];
  256. });
  257. };
  258. }
  259. return _infoViewController;
  260. }
  261. - (KMRepeatTrialAlertController *)repeatTrialAlertController {
  262. if (!_repeatTrialAlertController) {
  263. __block __typeof(self) blockSelf = self;
  264. _repeatTrialAlertController = [[KMRepeatTrialAlertController alloc] init];
  265. _repeatTrialAlertController.callback = ^(NSInteger clickIndex, KMRepeatTrialAlertController * _Nonnull tRController) {
  266. if (clickIndex == 0) {
  267. //免费试用
  268. [blockSelf verificationTrialForEmail:[VerificationManager manager].email
  269. name:[VerificationManager manager].accountName] ;
  270. } else if (clickIndex == 1) {
  271. //了解更多
  272. NSURL *url = [NSURL URLWithString:@"https://www.anyrecover.com/buy-pdf-editor-reader-converter"];
  273. [[NSWorkspace sharedWorkspace] openURL:url];
  274. [blockSelf close];
  275. // NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?utm_source=app_dmg&utm_medium=dmg_puw_sec_free_trial", Swift_oc_Tool.Store_Link_OC]];
  276. // [[NSWorkspace sharedWorkspace] openURL:url];
  277. // [blockSelf close];
  278. // KMPurchaseCompareDMGWindowController *singleTon = [[KMPurchaseCompareDMGWindowController alloc] init];
  279. // [singleTon showWindow:nil];
  280. } else if (clickIndex == 2) {
  281. //输入序列码
  282. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
  283. vc.callback = ^{
  284. };
  285. [vc showWindow:nil];
  286. }
  287. };
  288. }
  289. return _repeatTrialAlertController;
  290. }
  291. - (KMRepeatVerifyExpireController *)repeatTrialExpireController {
  292. if (!_repeatTrialExpireController) {
  293. __block __typeof(self) blockSelf = self;
  294. _repeatTrialExpireController = [[KMRepeatVerifyExpireController alloc] init];
  295. _repeatTrialExpireController.callback = ^(NSInteger clickIndex, KMRepeatVerifyExpireController * _Nonnull tRController) {
  296. if (clickIndex == 0) {
  297. [blockSelf setContentView:blockSelf.activateViewController.view];
  298. } else if (clickIndex == 1) {
  299. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"Btn_PUW_SecondTrialExpire_Later"}];
  300. [blockSelf close];
  301. } else if (clickIndex == 2) {
  302. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"Btn_PUW_SecondTrialExpire_Buy"}];
  303. [blockSelf verificationBuy];
  304. }
  305. };
  306. }
  307. return _repeatTrialExpireController;
  308. }
  309. - (KMTrialSuccessController *)trialSuccessController {
  310. if (!_trialSuccessController) {
  311. __block __typeof(self) blockSelf = self;
  312. _trialSuccessController = [[KMTrialSuccessController alloc] init];
  313. _trialSuccessController.clickHandle = ^(KMTrialSuccessController * _Nonnull controller) {
  314. [blockSelf close];
  315. };
  316. }
  317. return _trialSuccessController;
  318. }
  319. - (KMUnbindAlertViewController *)unbindAlertController {
  320. if (!_unbindAlertController) {
  321. __weak typeof(self) weakSelf = self;
  322. _unbindAlertController = [[KMUnbindAlertViewController alloc] init];
  323. _unbindAlertController.unbundHandle = ^(KMUnbindAlertViewController * _Nonnull controller) {
  324. [weakSelf unbindAction];
  325. [weakSelf close];
  326. };
  327. }
  328. return _unbindAlertController;
  329. }
  330. #pragma mark - Window Methods
  331. - (void)windowDidLoad {
  332. [super windowDidLoad];
  333. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
  334. self.window.title = @"";
  335. [[self.window standardWindowButton:NSWindowZoomButton] setHidden:YES];
  336. [[self.window standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
  337. [self updateViewInfo];
  338. [self updateViewColor];
  339. [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
  340. }
  341. - (void)updateViewInfo {
  342. if (KMVerificationTypeNormal == self.type) {
  343. [self setContentView:self.normalViewController.view];
  344. } else if (KMVerificationTypeActivate == self.type) {
  345. [self setContentView:self.activateViewController.view];
  346. } else if (KMVerificationTypeTrial == self.type) {
  347. [self setContentView:self.trialViewController.view];
  348. } else if (KMVerificationTypeActivateExpired == self.type) {
  349. [self setContentView:self.expiredViewController.view];
  350. } else if (KMVerificationTypeTrialExpired == self.type) {
  351. [self setContentView:self.normalViewController.view];
  352. } else if (KMVerificationTypeInfo == self.type) {
  353. [self setContentView:self.infoViewController.view];
  354. } else if (KMVerificationTypeRepeatTrialGuide == self.type) {
  355. self.window.title = @"";
  356. [self setContentView:self.repeatTrialAlertController.view];
  357. [[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"allowRepeatTrialAlertShowKey"];
  358. [[NSUserDefaults standardUserDefaults] synchronize];
  359. } else if (KMVerificationTypeRepeatTrialExpire == self.type) {
  360. [self setContentView:self.repeatTrialExpireController.view];
  361. [[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"allowRepeatTrialExpireShowKey"];
  362. [[NSUserDefaults standardUserDefaults] synchronize];
  363. } else if (self.type == KMVerificationTypeTrialSuccess ||
  364. self.type == KMVerificationTypeRepeatTrialSuccess) {
  365. [self setContentView:self.trialSuccessController.view];
  366. } else if (KMVerificationTypeActivateAIInfo == self.type) {
  367. [self setContentView:self.activateViewController.view];
  368. self.activateViewController.type = self.type;
  369. } else if (KMVerificationTypeUnbindAlert == self.type) {
  370. [self setContentView:self.unbindAlertController.view];
  371. }
  372. }
  373. - (void)updateViewColor {
  374. if (KMVerificationTypeNormal == self.type) {
  375. } else if (KMVerificationTypeActivate == self.type) {
  376. } else if (KMVerificationTypeTrial == self.type) {
  377. } else if (KMVerificationTypeActivateExpired == self.type) {
  378. } else if (KMVerificationTypeTrialExpired == self.type) {
  379. } else if (KMVerificationTypeInfo == self.type) {
  380. } else if (KMVerificationTypeRepeatTrialGuide == self.type) {
  381. [self.repeatTrialAlertController updateViewColor];
  382. } else if (KMVerificationTypeRepeatTrialExpire == self.type) {
  383. [self.repeatTrialExpireController updateViewColor];
  384. } else if (KMVerificationTypeTrialSuccess == self.type ||
  385. KMVerificationTypeRepeatTrialSuccess == self.type) {
  386. [self.trialSuccessController updateViewColor];
  387. } else if (KMVerificationTypeUnbindAlert == self.type) {
  388. [self.unbindAlertController updateViewColor];
  389. }
  390. }
  391. - (void)showWindow:(id)sender {
  392. if (!_currentWindowController) {
  393. _currentWindowController = self;
  394. }
  395. [super showWindow:sender];
  396. }
  397. - (void)windowWillClose:(NSNotification *)notification {
  398. if (_currentWindowController) {
  399. _currentWindowController = nil;
  400. }
  401. }
  402. #pragma mark - Setter
  403. - (void)setContentView:(NSView *)view {
  404. NSRect frame = self.window.frame;
  405. frame.origin.y -= view.frame.size.height-frame.size.height;
  406. frame.origin.x -= (view.frame.size.width-frame.size.width)/2.0;
  407. frame.size.width = view.frame.size.width;
  408. frame.size.height = view.frame.size.height;
  409. [self.box setContentView:view];
  410. [self.window setFrame:frame display:YES animate:YES];
  411. }
  412. #pragma mark - Private Methods
  413. - (void)verificationTrialForEmail:(NSString *)email name:(NSString *)name {
  414. if (email.length <= 0) {
  415. return;
  416. }
  417. if (![self isConnectionAvailable]) {
  418. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Connection Error", nil)
  419. defaultButton:NSLocalizedString(@"OK", nil)
  420. alternateButton:nil
  421. otherButton:nil
  422. informativeTextWithFormat:NSLocalizedString(@"Please make sure your internet connection is available.", nil), nil];
  423. [alert runModal];
  424. return;
  425. }
  426. __block __typeof(self) blockSelf = self;
  427. self.progressIndicator.hidden = NO;
  428. [self.progressIndicator startAnimation:nil];
  429. [self.trialViewController setEnabled:NO];
  430. [[VerificationManager manager] trialForDays:7 email:email name:name complention:^(ActivityStatus status, NSDictionary *info, NSError *error) {
  431. blockSelf.progressIndicator.hidden = YES;
  432. [blockSelf.progressIndicator stopAnimation:nil];
  433. [blockSelf.trialViewController setEnabled:YES];
  434. if (error ||
  435. status != ActivityStatusTrial) {
  436. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  437. defaultButton:NSLocalizedString(@"Try Again", nil)
  438. alternateButton:nil
  439. otherButton:nil
  440. informativeTextWithFormat:NSLocalizedString(@"Failed to sign up for the free trial. Please make sure your internet connection is available and try again later.", nil), nil];
  441. [alert runModal];
  442. } else {
  443. blockSelf.type = KMVerificationTypeTrialSuccess;
  444. [blockSelf updateViewInfo];
  445. }
  446. }];
  447. }
  448. - (void)verificationActivateAIInfo:(NSString *)license {
  449. if (license.length <= 0) {
  450. return;
  451. }
  452. if (![self isConnectionAvailable]) {
  453. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Connection Error", nil)
  454. defaultButton:NSLocalizedString(@"OK", nil)
  455. alternateButton:nil
  456. otherButton:nil
  457. informativeTextWithFormat:@"", nil];
  458. NSButton *accessryBtn = [[NSButton alloc] initWithFrame:CGRectMake(0, 0, 180, 44)];
  459. accessryBtn.autoresizingMask = NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin;
  460. accessryBtn.bezelStyle = NSBezelStyleRegularSquare;
  461. accessryBtn.bordered = NO;
  462. accessryBtn.target = self;
  463. accessryBtn.action = @selector(accessryBtnClicked:);
  464. NSMutableAttributedString *mutAttrString = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Please make sure your internet connection is available.", nil)];
  465. [mutAttrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [mutAttrString length])];
  466. [mutAttrString addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:12] range:NSMakeRange(0, [mutAttrString length])];
  467. [mutAttrString addAttribute:NSForegroundColorAttributeName value:[KMAppearance KMColor_Interactive_M0] range:NSMakeRange(0, [mutAttrString length])];
  468. accessryBtn.attributedTitle = mutAttrString;
  469. NSRect rect = [mutAttrString boundingRectWithSize:CGSizeMake(180, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
  470. CGRect frame = accessryBtn.frame;
  471. frame.size.height = rect.size.height;
  472. accessryBtn.frame = frame;
  473. alert.accessoryView = accessryBtn;
  474. [alert runModal];
  475. return;
  476. }
  477. __block __typeof(self) blockSelf = self;
  478. self.progressIndicator.hidden = NO;
  479. [self.progressIndicator startAnimation:nil];
  480. [self.activateViewController setEnabled:NO];
  481. NSDictionary *infoDic = @{@"cdkey":license};
  482. [[AIInfoManager defaultManager] activateAIWithInfo:infoDic complention:^(NSDictionary *info, NSError *error) {
  483. blockSelf.progressIndicator.hidden = YES;
  484. [blockSelf.progressIndicator stopAnimation:nil];
  485. [blockSelf.activateViewController setEnabled:YES];
  486. if (error) {
  487. NSString *tTitle0 = NSLocalizedString(@"The license you have entered is not correct. Please enter valid license.", nil);
  488. NSString *tTitle1 = NSLocalizedString(@"Please confirm your PDFull AI license code through the email you provided when purchasing.", nil);
  489. NSString *message = [NSString stringWithFormat:@"%@\n\n%@", tTitle0, tTitle1];
  490. if (ActivityErrorTypeCDKeyEmpty == error.code) {
  491. message = [NSString stringWithFormat:@"%@\n\n%@", NSLocalizedString(@"License number can not be empty.", nil), @""];
  492. } else if (ActivityErrorTypeCDKeyNotExist == error.code) {
  493. message = [NSString stringWithFormat:@"%@\n\n%@", NSLocalizedString(@"License number does not exist.", nil), @""];
  494. } else if (ActivityErrorTypeOutNumber == error.code) {
  495. NSString *tMsg0 = NSLocalizedString(@"The devices connected to the license number has outnumbered.", nil);
  496. NSString *tMsg1 = NSLocalizedString(@"Please deactivate license on one of them, to use PDFull on this computer", nil);
  497. message = [NSString stringWithFormat:@"%@\n\n%@", tMsg0, tMsg1];
  498. } else if (ActivityErrorTypeNetworkDisable == error.code) {
  499. message = NSLocalizedString(@"The network is unavailable.", nil);
  500. } else if (ActivityErrorTypeCDKeyExpire == error.code) {
  501. message = NSLocalizedString(@"The license number expired.", nil);
  502. } else if (ActivityErrorTypeInvalidInfo == error.code) {
  503. message = NSLocalizedString(@"Activation error. Please try to input correct license, or contact us.", nil);
  504. } else if (ActivityErrorTypeNotMatchProduct == error.code) {
  505. message = NSLocalizedString(@"The license number is wrong, please input right license which is for this app.", nil);
  506. } else if (ActivityErrorTypeFormatError == error.code) {
  507. message = NSLocalizedString(@"Error license. Please enter an AI license.", nil);
  508. }
  509. if ((ActivityErrorTypeUnknow == error.code) || (ActivityErrorTypeOutNumber == error.code) || (ActivityErrorTypeInvalidInfo == error.code)) {
  510. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  511. defaultButton:NSLocalizedString(@"Contact Us", nil)
  512. alternateButton:NSLocalizedString(@"Try Again", nil)
  513. otherButton:nil
  514. informativeTextWithFormat:message, nil];
  515. if ([alert runModal]) {
  516. [blockSelf verificationFeedback];
  517. }
  518. } else {
  519. if (ActivityErrorTypeNetworkDisable == error.code) {
  520. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Connection Error", nil)
  521. defaultButton:NSLocalizedString(@"OK", nil)
  522. alternateButton:nil
  523. otherButton:nil
  524. informativeTextWithFormat:@"", nil];
  525. NSButton *accessryBtn = [[NSButton alloc] initWithFrame:CGRectMake(0, 0, 180, 44)];
  526. accessryBtn.autoresizingMask = NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin;
  527. accessryBtn.bezelStyle = NSBezelStyleRegularSquare;
  528. accessryBtn.bordered = NO;
  529. accessryBtn.target = self;
  530. accessryBtn.action = @selector(accessryBtnClicked:);
  531. NSMutableAttributedString *mutAttrString = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Please make sure your internet connection is available.", nil)];
  532. [mutAttrString addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:12] range:NSMakeRange(0, [mutAttrString length])];
  533. [mutAttrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [mutAttrString length])];
  534. [mutAttrString addAttribute:NSForegroundColorAttributeName value:[KMAppearance KMColor_Interactive_M0] range:NSMakeRange(0, [mutAttrString length])];
  535. accessryBtn.attributedTitle = mutAttrString;
  536. NSRect rect = [mutAttrString boundingRectWithSize:CGSizeMake(180, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
  537. CGRect frame = accessryBtn.frame;
  538. frame.size.height = rect.size.height;
  539. accessryBtn.frame = frame;
  540. alert.accessoryView = accessryBtn;
  541. [alert runModal];
  542. } else {
  543. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  544. defaultButton:NSLocalizedString(@"Try Again", nil)
  545. alternateButton:nil
  546. otherButton:nil
  547. informativeTextWithFormat:message, nil];
  548. [alert runModal];
  549. }
  550. }
  551. } else {
  552. blockSelf.activityAlertViewController.alertTitle = NSLocalizedString(@"Successful Activation!", nil);
  553. blockSelf.activityAlertViewController.alertMessage = NSLocalizedString(@"Congratulations! You can start using PDFull AI features.", nil);
  554. [blockSelf setContentView:blockSelf.activityAlertViewController.view];
  555. }
  556. }];
  557. }
  558. - (void)verificationActivate:(NSString *)license {
  559. if (license.length <= 0) {
  560. return;
  561. }
  562. // if ([license hasPrefix:@"AI-"]) {
  563. // NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  564. // defaultButton:NSLocalizedString(@"Try Again", nil)
  565. // alternateButton:nil
  566. // otherButton:nil
  567. // informativeTextWithFormat:NSLocalizedString(@"To activate the AI license code, click “AI Tools” on the toolbar, then tap “My AI Credit” from the right panel.", nil), nil];
  568. // [alert runModal];
  569. // return;
  570. // }
  571. if (![self isConnectionAvailable]) {
  572. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Connection Error", nil)
  573. defaultButton:NSLocalizedString(@"OK", nil)
  574. alternateButton:nil
  575. otherButton:nil
  576. informativeTextWithFormat:@"", nil];
  577. NSButton *accessryBtn = [[NSButton alloc] initWithFrame:CGRectMake(0, 0, 180, 44)];
  578. accessryBtn.autoresizingMask = NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin;
  579. accessryBtn.bezelStyle = NSBezelStyleRegularSquare;
  580. accessryBtn.bordered = NO;
  581. accessryBtn.target = self;
  582. accessryBtn.action = @selector(accessryBtnClicked:);
  583. NSMutableAttributedString *mutAttrString = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Please make sure your internet connection is available.", nil)];
  584. [mutAttrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [mutAttrString length])];
  585. [mutAttrString addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:12] range:NSMakeRange(0, [mutAttrString length])];
  586. [mutAttrString addAttribute:NSForegroundColorAttributeName value:[KMAppearance KMColor_Interactive_M0] range:NSMakeRange(0, [mutAttrString length])];
  587. accessryBtn.attributedTitle = mutAttrString;
  588. NSRect rect = [mutAttrString boundingRectWithSize:CGSizeMake(180, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
  589. CGRect frame = accessryBtn.frame;
  590. frame.size.height = rect.size.height;
  591. accessryBtn.frame = frame;
  592. alert.accessoryView = accessryBtn;
  593. [alert runModal];
  594. return;
  595. }
  596. __block __typeof(self) blockSelf = self;
  597. self.progressIndicator.hidden = NO;
  598. [self.progressIndicator startAnimation:nil];
  599. [self.activateViewController setEnabled:NO];
  600. NSDictionary *infoDic = @{@"cdkey":license};
  601. [[VerificationManager manager] activateDeviceWithInfo:infoDic complention:^(ActivityStatus status, NSDictionary *info, NSError *error) {
  602. blockSelf.progressIndicator.hidden = YES;
  603. [blockSelf.progressIndicator stopAnimation:nil];
  604. [blockSelf.activateViewController setEnabled:YES];
  605. if (error) {
  606. NSString *tTitle0 = NSLocalizedString(@"The license you have entered is not correct. Please enter valid license.", nil);
  607. NSString *tTitle1 = NSLocalizedString(@"If you have already purchased PDFull for Mac, you should find your license in an email confirmation.", nil);
  608. NSString *message = [NSString stringWithFormat:@"%@\n\n%@", tTitle0, tTitle1];
  609. if (ActivityErrorTypeCDKeyEmpty == error.code) {
  610. message = [NSString stringWithFormat:@"%@\n\n%@", NSLocalizedString(@"License number can not be empty.", nil), @""];
  611. } else if (ActivityErrorTypeCDKeyNotExist == error.code) {
  612. message = [NSString stringWithFormat:@"%@\n\n%@", NSLocalizedString(@"License number does not exist.", nil), @""];
  613. } else if (ActivityErrorTypeOutNumber == error.code) {
  614. NSString *tMsg0 = NSLocalizedString(@"The devices connected to the license number has outnumbered.", nil);
  615. NSString *tMsg1 = NSLocalizedString(@"Please deactivate license on one of them, to use PDFull on this computer", nil);
  616. message = [NSString stringWithFormat:@"%@\n\n%@", tMsg0, tMsg1];
  617. } else if (ActivityErrorTypeNetworkDisable == error.code) {
  618. message = NSLocalizedString(@"The network is unavailable.", nil);
  619. } else if (ActivityErrorTypeCDKeyExpire == error.code) {
  620. message = NSLocalizedString(@"The license number expired.", nil);
  621. } else if (ActivityErrorTypeInvalidInfo == error.code) {
  622. message = NSLocalizedString(@"Activation error. Please try to input correct license, or contact us.", nil);
  623. } else if (ActivityErrorTypeNotMatchProduct == error.code) {
  624. message = NSLocalizedString(@"The license number is wrong, please input right license which is for this app.", nil);
  625. } else if (ActivityErrorTypeFormatError == error.code) {
  626. message = NSLocalizedString(@"The license format is wrong. Please input correct license.", nil);
  627. }
  628. if ((ActivityErrorTypeUnknow == error.code) || (ActivityErrorTypeOutNumber == error.code) || (ActivityErrorTypeInvalidInfo == error.code)) {
  629. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  630. defaultButton:NSLocalizedString(@"Contact Us", nil)
  631. alternateButton:NSLocalizedString(@"Try Again", nil)
  632. otherButton:nil
  633. informativeTextWithFormat:message, nil];
  634. if ([alert runModal]) {
  635. [blockSelf verificationFeedback];
  636. }
  637. } else {
  638. if (ActivityErrorTypeNetworkDisable == error.code) {
  639. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Connection Error", nil)
  640. defaultButton:NSLocalizedString(@"OK", nil)
  641. alternateButton:nil
  642. otherButton:nil
  643. informativeTextWithFormat:@"", nil];
  644. NSButton *accessryBtn = [[NSButton alloc] initWithFrame:CGRectMake(0, 0, 180, 44)];
  645. accessryBtn.autoresizingMask = NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin;
  646. accessryBtn.bezelStyle = NSBezelStyleRegularSquare;
  647. accessryBtn.bordered = NO;
  648. accessryBtn.target = self;
  649. accessryBtn.action = @selector(accessryBtnClicked:);
  650. NSMutableAttributedString *mutAttrString = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Please make sure your internet connection is available.", nil)];
  651. [mutAttrString addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:12] range:NSMakeRange(0, [mutAttrString length])];
  652. [mutAttrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [mutAttrString length])];
  653. [mutAttrString addAttribute:NSForegroundColorAttributeName value:[KMAppearance KMColor_Interactive_M0] range:NSMakeRange(0, [mutAttrString length])];
  654. accessryBtn.attributedTitle = mutAttrString;
  655. NSRect rect = [mutAttrString boundingRectWithSize:CGSizeMake(180, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
  656. CGRect frame = accessryBtn.frame;
  657. frame.size.height = rect.size.height;
  658. accessryBtn.frame = frame;
  659. alert.accessoryView = accessryBtn;
  660. [alert runModal];
  661. } else {
  662. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  663. defaultButton:NSLocalizedString(@"Try Again", nil)
  664. alternateButton:nil
  665. otherButton:nil
  666. informativeTextWithFormat:message, nil];
  667. [alert runModal];
  668. }
  669. }
  670. } else {
  671. blockSelf.activityAlertViewController.alertTitle = NSLocalizedString(@"Successful Activation!", nil);
  672. blockSelf.activityAlertViewController.alertMessage = NSLocalizedString(@"Congrats! You are eligible to enjoy all advanced features in PDFull.", nil);
  673. [blockSelf setContentView:blockSelf.activityAlertViewController.view];
  674. }
  675. }];
  676. }
  677. - (void)verificationBuy {
  678. #if VERSION_DMG
  679. NSURL *url = [NSURL URLWithString:@"https://www.anyrecover.com/buy-pdf-editor-reader-converter"];
  680. if([SKInspectPublicTool currentisLanguageHans]) {
  681. url = [NSURL URLWithString:@"https://www.anyrecover.com/buy-pdf-editor-reader-converter"];
  682. }
  683. [[NSWorkspace sharedWorkspace] openURL:url];
  684. // NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?utm_source=MacAppDmg&utm_campaign=StoreLink&utm_medium=PdfStore", Swift_oc_Tool.Store_Link_OC]];
  685. // [[NSWorkspace sharedWorkspace] openURL:url];
  686. // KMPurchaseCompareDMGWindowController *singleTon = [[KMPurchaseCompareDMGWindowController alloc] init];
  687. // [singleTon showWindow:nil];
  688. #endif
  689. }
  690. #pragma - 验证错误时反馈信息
  691. - (void)verificationFeedback {
  692. unsigned major, minor, bugFix;
  693. [self getSystemVersionMajor:&major minor:&minor bugFix:&bugFix];
  694. NSString *versionString = [NSString stringWithFormat:@"%@ - %u.%u.%u", [GBDeviceInfo deviceInfo].rawSystemInfoString, major, minor, bugFix];
  695. //application version (use short version preferentially)
  696. NSString *tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
  697. if ([tAppVersion length] < 1) {
  698. tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
  699. }
  700. NSString* subjects = [[self getAppNameForSupportEmail] stringByAppendingFormat:NSLocalizedString(@" - %@;Verification Feedback;%@", nil) ,tAppVersion,versionString];
  701. [KMMailHelper newEmailWithContacts:@"support@anyrecover.com" andSubjects:subjects];
  702. }
  703. - (void)unbindAction {
  704. unsigned major, minor, bugFix;
  705. [self getSystemVersionMajor:&major minor:&minor bugFix:&bugFix];
  706. NSString *versionString = [NSString stringWithFormat:@"%@ - %u.%u.%u", [GBDeviceInfo deviceInfo].rawSystemInfoString, major, minor, bugFix];
  707. //application version (use short version preferentially)
  708. NSString *tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
  709. if ([tAppVersion length] < 1) {
  710. tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
  711. }
  712. NSString *subjects = [[self getAppNameForEmail] stringByAppendingString:[NSString stringWithFormat:@" %@",@"Verification:"]];
  713. subjects = [subjects stringByAppendingString:[NSString stringWithFormat:@"%@;",tAppVersion]];
  714. subjects = [subjects stringByAppendingString:[NSString stringWithFormat:@" %@;",versionString]];
  715. subjects = [subjects stringByAppendingString:[NSString stringWithFormat:@" %@",NSLocalizedString(@"Unbind License Code:", nil)]];
  716. subjects = [subjects stringByAppendingString:[NSString stringWithFormat:@"%@",[VerificationManager manager].detailInfo[@"device"][@"uniqueSn"]?:GetHardwareUUID()?:@""]];
  717. NSString *mailtoAddress = [NSString stringWithFormat:@"mailto:%@?Subject=%@&body=%@",@"support@anyrecover.com",[self URLEncodedString:subjects],[self URLEncodedString:NSLocalizedString(@"Hi PDFull Team, I need to unbind my license code, thanks!\nNotice: Please do not modify the subtitle content", nil)]];
  718. [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:mailtoAddress]];
  719. }
  720. - (void)accessryBtnClicked:(NSButton *)btn {
  721. [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.pdfreaderpro.com/mac/help/activate-license-code-mac"]];
  722. }
  723. - (NSString *)URLEncodedString:(NSString *)string {
  724. CFStringRef stringRef = CFBridgingRetain(string);
  725. #pragma clang diagnostic push
  726. #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  727. CFStringRef encoded = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
  728. stringRef,
  729. NULL,
  730. CFSTR("!*'\"();:@&=+$,/?%#[]% "),
  731. kCFStringEncodingUTF8);
  732. #pragma clang diagnostic pop
  733. CFRelease(stringRef);
  734. return CFBridgingRelease(encoded);
  735. }
  736. - (void)getSystemVersionMajor:(unsigned *)major
  737. minor:(unsigned *)minor
  738. bugFix:(unsigned *)bugFix {
  739. OSErr err;
  740. SInt32 systemVersion, versionMajor, versionMinor, versionBugFix;
  741. if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) {
  742. NSOperatingSystemVersion osSystemVersion = [[NSProcessInfo processInfo] operatingSystemVersion];
  743. *major = (unsigned)osSystemVersion.majorVersion;
  744. *minor = (unsigned)osSystemVersion.minorVersion;
  745. *bugFix = (unsigned)osSystemVersion.patchVersion;
  746. return;
  747. } else {
  748. #pragma clang diagnostic push
  749. #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  750. if ((err = Gestalt(gestaltSystemVersion, &systemVersion)) != noErr) goto fail;
  751. if (systemVersion < 0x1040)
  752. {
  753. if (major) *major = ((systemVersion & 0xF000) >> 12) * 10 +
  754. ((systemVersion & 0x0F00) >> 8);
  755. if (minor) *minor = (systemVersion & 0x00F0) >> 4;
  756. if (bugFix) *bugFix = (systemVersion & 0x000F);
  757. }
  758. else
  759. {
  760. if ((err = Gestalt(gestaltSystemVersionMajor, &versionMajor)) != noErr) goto fail;
  761. if ((err = Gestalt(gestaltSystemVersionMinor, &versionMinor)) != noErr) goto fail;
  762. if ((err = Gestalt(gestaltSystemVersionBugFix, &versionBugFix)) != noErr) goto fail;
  763. if (major) *major = versionMajor;
  764. if (minor) *minor = versionMinor;
  765. if (bugFix) *bugFix = versionBugFix;
  766. }
  767. return;
  768. #pragma clang diagnostic pop
  769. }
  770. fail:
  771. NSLog(@"Unable to obtain system version: %ld", (long)err);
  772. if (major) *major = 10;
  773. if (minor) *minor = 0;
  774. if (bugFix) *bugFix = 0;
  775. }
  776. - (NSString *)getAppNameForEmail {
  777. NSString *tAppName = @"PDFull Mac";
  778. #if VERSION_FREE
  779. #if VERSION_DMG
  780. #else
  781. // AppStore 免费版本
  782. tAppName = @"PDF Reader Pro Lite";
  783. #endif
  784. #else
  785. // AppStore 付费版
  786. tAppName = @"PDF Reader Pro Edition";
  787. #endif
  788. return tAppName;
  789. }
  790. - (NSString *)getAppNameForSupportEmail {
  791. NSString *tAppName = @"PDFull";
  792. #if VERSION_FREE
  793. #if VERSION_DMG
  794. // 桌机版
  795. VerificationManager *tManager = [VerificationManager manager];
  796. switch ([tManager status]) {
  797. case ActivityStatusTrial:
  798. tAppName = @"PDFull Trial";
  799. break;
  800. case ActivityStatusVerification:
  801. tAppName = @"PDFull Verification";
  802. break;
  803. case ActivityStatusTrialExpire:
  804. tAppName = @"PDFull TrialExpire";
  805. break;
  806. case ActivityStatusVerifExpire:
  807. tAppName = @"PDFull VerifExpire";
  808. break;
  809. default:
  810. break;
  811. }
  812. #else
  813. // AppStore 免费版本
  814. tAppName = @"PDF Reader Pro Lite";
  815. #endif
  816. #else
  817. // AppStore 付费版
  818. tAppName = @"PDF Reader Pro Edition";
  819. #endif
  820. return tAppName;
  821. }
  822. - (BOOL)isConnectionAvailable {
  823. BOOL isExistenceNetwork = YES;
  824. Reachability *reach = [Reachability reachabilityWithHostname:@"www.apple.com"];
  825. switch ([reach currentReachabilityStatus]) {
  826. case NotReachable:
  827. isExistenceNetwork = NO;
  828. //NSLog(@"notReachable");
  829. break;
  830. case ReachableViaWiFi:
  831. isExistenceNetwork = YES;
  832. //NSLog(@"WIFI");
  833. break;
  834. case ReachableViaWWAN:
  835. isExistenceNetwork = YES;
  836. //NSLog(@"3G");
  837. break;
  838. }
  839. if (NotReachable == [[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) {
  840. return NO;
  841. }
  842. return YES;
  843. }
  844. #pragma mark - NSNotification
  845. - (void)themeChanged:(NSNotification *)notification {
  846. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  847. [self updateViewColor];
  848. });
  849. }
  850. + (void)verificationFeedback {
  851. unsigned major, minor, bugFix;
  852. [self getSystemVersionMajor:&major minor:&minor bugFix:&bugFix];
  853. NSString *versionString = [NSString stringWithFormat:@"%@ - %u.%u.%u", [GBDeviceInfo deviceInfo].rawSystemInfoString, major, minor, bugFix];
  854. NSString *tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
  855. if ([tAppVersion length] < 1)
  856. {
  857. tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
  858. }
  859. NSString* subjects = [[self getAppNameForSupportEmail] stringByAppendingFormat:NSLocalizedString(@" - %@;Verification Feedback;%@", nil) ,tAppVersion,versionString];
  860. [KMMailHelper newEmailWithContacts:@"support@anyrecover.com" andSubjects:subjects];
  861. }
  862. + (void)getSystemVersionMajor:(unsigned *)major
  863. minor:(unsigned *)minor
  864. bugFix:(unsigned *)bugFix;
  865. {
  866. OSErr err;
  867. SInt32 systemVersion, versionMajor, versionMinor, versionBugFix;
  868. if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) {
  869. NSOperatingSystemVersion osSystemVersion = [[NSProcessInfo processInfo] operatingSystemVersion];
  870. *major = (unsigned)osSystemVersion.majorVersion;
  871. *minor = (unsigned)osSystemVersion.minorVersion;
  872. *bugFix = (unsigned)osSystemVersion.patchVersion;
  873. return;
  874. } else {
  875. #pragma clang diagnostic push
  876. #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  877. if ((err = Gestalt(gestaltSystemVersion, &systemVersion)) != noErr) goto fail;
  878. if (systemVersion < 0x1040)
  879. {
  880. if (major) *major = ((systemVersion & 0xF000) >> 12) * 10 +
  881. ((systemVersion & 0x0F00) >> 8);
  882. if (minor) *minor = (systemVersion & 0x00F0) >> 4;
  883. if (bugFix) *bugFix = (systemVersion & 0x000F);
  884. }
  885. else
  886. {
  887. if ((err = Gestalt(gestaltSystemVersionMajor, &versionMajor)) != noErr) goto fail;
  888. if ((err = Gestalt(gestaltSystemVersionMinor, &versionMinor)) != noErr) goto fail;
  889. if ((err = Gestalt(gestaltSystemVersionBugFix, &versionBugFix)) != noErr) goto fail;
  890. if (major) *major = versionMajor;
  891. if (minor) *minor = versionMinor;
  892. if (bugFix) *bugFix = versionBugFix;
  893. }
  894. return;
  895. #pragma clang diagnostic pop
  896. }
  897. fail:
  898. NSLog(@"Unable to obtain system version: %ld", (long)err);
  899. if (major) *major = 10;
  900. if (minor) *minor = 0;
  901. if (bugFix) *bugFix = 0;
  902. }
  903. + (NSString *)getAppNameForSupportEmail
  904. {
  905. NSString *tAppName = @"PDFull";
  906. #if VERSION_FREE
  907. #if VERSION_DMG
  908. // 桌机版
  909. VerificationManager *tManager = [VerificationManager manager];
  910. switch ([tManager status]) {
  911. case ActivityStatusTrial:
  912. tAppName = @"PDFull Trial";
  913. break;
  914. case ActivityStatusVerification:
  915. tAppName = @"PDFull Verification";
  916. break;
  917. case ActivityStatusTrialExpire:
  918. tAppName = @"PDFull TrialExpire";
  919. break;
  920. case ActivityStatusVerifExpire:
  921. tAppName = @"PDFull VerifExpire";
  922. break;
  923. default:
  924. break;
  925. }
  926. #else
  927. // AppStore 免费版本
  928. tAppName = @"PDF Reader Pro Lite";
  929. #endif
  930. #else
  931. // AppStore 付费版
  932. tAppName = @"PDF Reader Pro Edition";
  933. #endif
  934. return tAppName;
  935. }
  936. @end