KMVerificationWindowController.m 48 KB

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