12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526 |
- //
- // SceneDelegate.m
- // 唔即云相册
- //
- // Created by 余衡武 on 2021/12/8.
- //
- #import "SceneDelegate.h"
- #import "HWWebViewController.h"
- #import "CalculatorViewController.h"
- #import "SetUsePWDViewController.h"
- #import "GuideViewController.h"
- #import "BaseNavigationController.h"
- #import "MySetViewController.h"
- #import "SafeForKey.h"
- #import "TipsQRCodeViewController.h"
- #import "SetPWDFirstViewController.h"
- #import "connectDeviceManager.h"
- #import "inputPWDViewController.h"
- #import "customLaunchView.h"
- #import "RSATool.h"
- #import "forgetPwdViewController.h"
- #import "TipsQRCodeForChangeDeviceViewController.h"
- #import "AFNetworkReachabilityManager.h"
- #import "ComontAlretViewController.h"
- #import "uploadFileManager.h"
- //#import "downloadManager.h"
- #import "nasDownloadFileManager.h"
- //#import "backupsFileManager.h"
- #import "nasBackupsManager.h"
- #import "iPhone.h"
- #import <WXApi.h>
- #import <TencentOpenAPI/QQApiInterface.h>
- #import <TencentOpenAPI/TencentOAuth.h>
- #import "NASMsgModel.h"
- #import "queryOneShareModel.h"
- #import "boxSaveFileManager.h"
- #import "boxDownloadFileManager.h"
- #import "NASViewController.h"
- #import "cloudPhoneViewController.h"
- #import "mineViewController.h"
- #import "lastFileManager.h"
- #import "customDownloadManager.h"
- #import "audioPlayListManager.h"
- #import "QRCodeScanForChangeDeviceViewController.h"
- #import "customToastVew.h"
- #import "DFPlayer.h"
- #import "UIInterface+HXRotation.h"
- #import "imageDetailsScrollViewController.h"
- #import "videoPlayByAVPlayerViewController.h"
- #import "pingManager.h"
- #import "webRtcPlayerViewController.h"
- @interface SceneDelegate ()<SetUsePWDViewControllerDelegate,GuideViewControllerDelegate,UITabBarControllerDelegate>
- @property(nonatomic, strong) CalculatorViewController *calculatorVC;
- @property(nonatomic, strong) HWWebViewController *webVC;
- @property(nonatomic, strong) inputPWDViewController *inputVC;
- @property(nonatomic, strong) customLaunchView *customLaunchV;//
- @property(nonatomic, strong) BaseNavigationController *preRootPlayerNav;
- @property(nonatomic, assign) bool isQRCodeType;//第一次 扫码进来的
- //@property(nonatomic, assign) bool isNeedToShowSecretKey;//扫码进来的SN 没有密码 则需要显示秘钥
- @property (nonatomic, assign) BOOL isLoginAgainType;// 单点登录 点重新登录进来的
- @property (nonatomic, assign) BOOL isNeedToStopWork;// 无网络报错
- @property(nonatomic, copy) NSString *getShareStr;//拿到分享的字符串
- @property (nonatomic, assign) BOOL isFirstOpenInLaunch;//启动页停两秒
- //冷启动分享跳入用
- @property(nonatomic, strong) UISceneSession *session;
- @property(nonatomic, strong) UISceneConnectionOptions *connectionOptions;
- @end
- @implementation SceneDelegate
- - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions API_AVAILABLE(ios(13.0)){
- HLog(@"willConnectToSession")
- if (scene) {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(guideOk:) name:GuideOkNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showLockViewFun:) name:lockBypwdNotification object:nil];
-
- //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setPwdVCFun:) name:setPwdNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forgetPwdFun:) name:forgetPwdNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forgetPwdBackFun:) name:forgetPwdBackNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forgetPwdDidSetPwdFun:) name:forgetPwdDidSetNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scanChangeDeviceFun:) name:scanChangeDeviceNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scanChangeDeviceBackFun:) name:scanChangeDeviceBackNotification object:nil];
-
- UIWindowScene *windowScene = (UIWindowScene *)scene;
- self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
- self.window.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
-
- _isFirstOpenInLaunch = YES;
-
- // 初始化数据库
- [self initBrowserWindow];
- // 加载主页面
- [self enterMainVCFromScene];
- //
- [self reportVersionInfoFun];
-
- [self.window makeKeyAndVisible];
-
- ksharedAppDelegate.window = self.window;
-
- //冷启动
- if(connectionOptions.URLContexts != nil){
- _session = session;
- _connectionOptions = connectionOptions;
-
- // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // mainBlock(^{
- // [self scene:scene openURLContexts:connectionOptions.URLContexts];
- // });
- // });
- }
- }
- }
- /** 主界面 - 内部使用 */
- - (void)enterMainVCFromScene {
- // ConnectTestViewController *qrCodeVCNav = [[ConnectTestViewController alloc] init];
- // self.window.rootViewController = qrCodeVCNav;
- // return;/*临时测试*/
-
- if(_isNeedToStopWork){
- return;
- }
-
- /*先判断本地有无设备 无设备时需要先扫码添加设备*/
- NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
- if (!deviceDict || ![[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
-
- //默认显示最近文件
- [HWDataManager setBoolWithKey:Const_last_file_show value:YES];
-
- /*扫码界面*/
- TipsQRCodeViewController *qrCodeVC = [[TipsQRCodeViewController alloc] init];
- BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
- self.window.rootViewController = qrCodeVCNav;
-
- _isQRCodeType = YES;
- return;
- }
-
- NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
-
- // GuideViewController
- BOOL haveGuide = [HWDataManager getBoolWithKey:Const_Have_Show_Guide];
- if (haveGuide) {
- ;
- }else {
- GuideViewController *guiDeVC = [[GuideViewController alloc] init];
- guiDeVC.delegate = self;
- guiDeVC.sn = SNStr;
- self.window.rootViewController = guiDeVC;
-
- return;
- }
-
- //BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_Mask_View_Open];
- #ifdef developJSQ
- NSInteger maskModel = 1;// [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
- #else
- NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
- #endif
-
- //添加默认启动图片
- if(!_customLaunchV && maskModel == 0){
- _customLaunchV = [[customLaunchView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
- [self.window addSubview:_customLaunchV];
- }
-
-
- if(maskModel == 0 && _isFirstOpenInLaunch){
-
- //20240612 产品觉得 启动页太快了 要停两秒
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-
- if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
- {
- [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
- customToastVew *toastview = [customToastVew makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)];
- [toastview show];
- [self->_customLaunchV addSubview:toastview];
- return;
- }
-
- [self getDeviceMsgInMainVCWith:deviceDict];
- });
-
- _isFirstOpenInLaunch = NO;
- }
- else{
- //延时等网络状态
- if(_isFirstOpenInLaunch){
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self getDeviceMsgInMainVCWith:deviceDict];
- });
- _isFirstOpenInLaunch = NO;
- }
- else{
- [self getDeviceMsgInMainVCWith:deviceDict];
- }
-
- }
-
- //[self showNetErrorAlertType2Fun];
- }
- - (void)getDeviceMsgInMainVCWith:(NSDictionary*)deviceDict
- {
- if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
- {
- BOOL isPrivacyMode = [HWDataManager getBoolWithKey:Const_Have_Add_Device_Privacy_Mode];
- NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
- if(!isPrivacyMode && maskModel == 0){
- return;
- }
-
- [self initMainTabbarFun];
- [self showCalculatorVC];
- return;
- }
-
- KWeakSelf
- //有设备了先去做链接准备 // 80bec9c5
- NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
- NSString *sdnId = ksharedAppDelegate.DeviceThirdIdMod.data.sdnId;
- if(SNStr && !sdnId){
- //瑞云方案
- // [[connectDeviceManager shareInstance] getThridMsgBySN:SNStr needReconnect:YES didNetEnd:^(NSInteger didSuc) {
- //
- // if(didSuc == 0){
- // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // mainBlock(^{
- // [weakSelf showNetErrorAlertFun];
- // [weakSelf enterMainVCFromSceneSecondStepFun];
- // });
- // });
- // }
- // else if(didSuc == 2
- // ||didSuc == 201
- // ||didSuc == 202){
- // [weakSelf gotoScanAginByThridMsgErrorFun:didSuc];
- // }
- // else{
- // [weakSelf enterMainVCFromSceneSecondStepFun];
- // }
- //
- // }];
-
- //webrtc方案
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
- [paraDict setValue:SNStr forKey:@"sn"];
- KWeakSelf
- [[netWorkManager shareInstance] CommonGetWithCallBackCode:getThirdIdBySn Parameters:paraDict success:^(id _Nonnull responseObject) {
-
- DeviceThirdIdModel *model = [[DeviceThirdIdModel alloc] initWithDictionary:responseObject error:nil];
- if(model.status == 0
- && model.data)
- {//根据SN 获取到正确的信息
- ksharedAppDelegate.DeviceThirdIdMod = model;
-
- NSString*desPwdstr = [RSATool AES128Decrypt:model.data.password key:AESCODEKEEYY];
-
- /*密码保持在本地*/
- NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
- NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:deviceDict];
- [dict setObject:desPwdstr forKey:Const_Have_Add_Device_PWD];
-
- NSString *sdnid = model.data.sdnId;
-
- if(sdnid){
- [dict setObject:sdnid forKey:Const_Have_Add_Device_sdnid];
- }
-
- [HWDataManager setObjectWithKey:Const_Have_Add_Device_Privacy_Mode value:[NSNumber numberWithBool:model.data.isPrivacyMode]];
-
- [HWDataManager setObjectWithKey:Const_Have_Add_Device value:dict];
-
-
- [weakSelf enterMainVCFromSceneSecondStepFun];;
-
- //ping看上是否为内网情况
- [[pingManager shareManager] startPingDeviceIpFun];
- //获取webrtc相关信息
- [weakSelf queryWebRtcMsgFun];
- }
- else{
-
- //if(model.status == 201||model.status == 202 || model.status ==2){}
- [weakSelf gotoScanAginByThridMsgErrorFun:model.status];
- }
-
-
- } failure:^(NSError * _Nonnull error) {
- HLog("网络报错");
- mainBlock(^{
- [weakSelf showNetErrorAlertFun];
- [weakSelf enterMainVCFromSceneSecondStepFun];
- });
- }];
-
- }
- else{
- //ping看上是否为内网情况
- [[pingManager shareManager] startPingDeviceIpFun];
-
- if (!ksharedAppDelegate.DeviceWebRtcMsgMod) {
- //获取webrtc相关信息
- [weakSelf queryWebRtcMsgFun];
- }
- [self enterMainVCFromSceneSecondStepFun];
- }
- }
-
- #pragma mark 获取webrct 的链接信息
- -(void)queryWebRtcMsgFun
- {
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
- KWeakSelf
- [[netWorkManager shareInstance] CommonPostCallBackCode:webrctQueryByClient Parameters:paraDict success:^(id _Nonnull responseObject){
-
- webRtcMsgModel *curModel = [[webRtcMsgModel alloc] initWithDictionary:responseObject error:nil];
-
- if(curModel && curModel.status == 0){
- ksharedAppDelegate.DeviceWebRtcMsgMod = curModel;
- [[webRtcManager shareManager] beginToLinkWebRtcFun];
- }
- else
- {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf queryWebRtcMsgFun];
- });
- }
-
- } failure:^(NSError * _Nonnull error) {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf queryWebRtcMsgFun];
- });
- }];
- }
- - (void)enterMainVCFromSceneSecondStepFun
- {
-
- //确保通过SN号拿到密码了
- //非扫码进入 进入到这里很可能还没联网拿到设备最新信息
- if(!ksharedAppDelegate.DeviceThirdIdMod
- &&!ksharedAppDelegate.DeviceWebRtcMsgMod){
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- mainBlock(^{
- [self enterMainVCFromScene];
- });
- });
-
- return;
- }
-
- //是否已经有密码了 有就是输入密码 没有就是设置密码
- NSString *curPwd = ksharedAppDelegate.DeviceThirdIdMod.data.password;
- NSString * sdnId = ksharedAppDelegate.DeviceThirdIdMod.data.sdnId;
- if(!sdnId && !ksharedAppDelegate.DeviceWebRtcMsgMod){
- HLog(@"没有拿到 --sdnId:%@ --- DeviceWebRtcMsgMod:%@",sdnId,ksharedAppDelegate.DeviceWebRtcMsgMod);
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- mainBlock(^{
- [self enterMainVCFromScene];
- });
- });
-
- return;
- }
-
- if(_customLaunchV){
- [_customLaunchV removeFromSuperview];
- _customLaunchV = nil;
- }
-
- if(curPwd && curPwd.length > 0){
- /*设置密码*/
- // inputPWDViewController *nextVC = [[inputPWDViewController alloc] init];
- // BaseNavigationController *nextVCNav = [[BaseNavigationController alloc] initWithRootViewController:nextVC];
- // self.window.rootViewController = nextVCNav;
- }
- else{
- /*没有设置密码*/
- SetPWDFirstViewController *qrCodeVC = [[SetPWDFirstViewController alloc] init];
- BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
- self.window.rootViewController = qrCodeVCNav;
-
- return;
- }
-
- //下载配置先处理
- [boxDownloadFileManager shareInstance];
-
- [lastFileManager shareManager].uid = ksharedAppDelegate.DeviceThirdIdMod.data.sn;
- [audioPlayListManager shareManager].uid = ksharedAppDelegate.DeviceThirdIdMod.data.sn;
-
- //获取NAS相关信息
- [self getNASMsgFun];
-
- [self initMainTabbarFun];
-
- self.isLoginAgainType = NO;
- __block BOOL isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
- //KWeakSelf
- if(!_isQRCodeType){
- if(isPrivacyMode)
- {
- [self showCalculatorVC];
- }
- else{
- [self HandleEnterNotPrivacyModeFun];
- ksharedAppDelegate.isFirstInputPwdDone = YES;
- //playerRootVC.isPwdVCShow = NO;
- //[playerRootVC setShowImgAndVoiceTypeFun:YES];
- //[weakSelf shareAwakenAppBy:weakSelf.getShareStr];
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
- });
-
-
- if(self->_session && self->_connectionOptions){
- [self scene:self->_session openURLContexts:self->_connectionOptions.URLContexts];
- }
- }
- //_isQRCodeType = NO;
- }
- else{
- if(isPrivacyMode)
- {
- [self showCalculatorVC];
- }
- else{
- [[webRtcManager shareManager] beginToLinkWebRtcFun];
- ksharedAppDelegate.isFirstInputPwdDone = YES;
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
- });
- }
- }
- _isQRCodeType = NO;
-
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:1 withEventValue:@"Nas"];
- }
- #pragma mark 1.4.1 新增tabbar
- - (void)initMainTabbarFun
- {
- UITabBarController *tabBarController = [[UITabBarController alloc] init];
- tabBarController.delegate = self;
-
- //NASViewController *NASVC = [[NASViewController alloc] init];
- //BaseNavigationController *NasNav = [[BaseNavigationController alloc] initWithRootViewController:NASVC];
-
- cloudPhoneViewController *cloudVC = [[cloudPhoneViewController alloc] init];
- BaseNavigationController *cloudPhoneNav = [[BaseNavigationController alloc] initWithRootViewController:cloudVC];
- mineViewController *mineVC = [[mineViewController alloc] init];
- BaseNavigationController *mineNav = [[BaseNavigationController alloc] initWithRootViewController:mineVC];
-
- NSArray *viewControllers = @[/*NasNav,*/ cloudPhoneNav,mineNav]; // 添加更多视图控制器
- tabBarController.viewControllers = viewControllers;
-
- NSString*phoneTitle = NSLocalizedString(@"tabbar_cloud_phone",nil);
- NSString*myTitle = NSLocalizedString(@"tabbar_my_title",nil);
-
- NSArray *titleArr = @[/*@"NAS",*/phoneTitle,myTitle];
- NSArray *imageNArr = @[/*@"tabbar_nas_N",*/ @"tabbar_phone_N",@"tabbar_my_N"];
- NSArray *imageHArr = @[/*@"tabbar_nas_H",*/ @"tabbar_phone_H",@"tabbar_my_H"];
-
- for (int i=0; i<viewControllers.count; i++) {
- UITabBarItem * tabBarItem = [UITabBarItem new];
- tabBarItem.title = titleArr[i];
- tabBarItem.selectedImage = [[UIImage imageNamed:imageHArr[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
- tabBarItem.image = [[UIImage imageNamed:imageNArr[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
-
- UIViewController *curVC = viewControllers[i];
- curVC.tabBarItem = tabBarItem;
- }
-
- //tabBarController.tabBar.barTintColor = [UIColor hwColor:@"#F6F8FA"]; // 设置标签栏背景色
- tabBarController.tabBar.tintColor = [UIColor hwColor:@"#01B7EA"]; // 设置选中标签项的颜色
- tabBarController.tabBar.unselectedItemTintColor = [UIColor hwColor:@"#7C8196"]; // 设置未选中标签项的颜色
- tabBarController.tabBar.backgroundColor = [UIColor whiteColor];
- // [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor hwColor:@"#01B7EA"],NSForegroundColorAttributeName, [UIFont systemFontOfSize:12.0],NSFontAttributeName,nil] forState:UIControlStateSelected];
- // //[UIColor hwColor:@"#7C8196"]
- // [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor],NSForegroundColorAttributeName, [UIFont systemFontOfSize:12.0],NSFontAttributeName,nil] forState:UIControlStateNormal];
-
- BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_cloudPhone_Model_Open];
- if(haveOpenMask){
-
- //非隐私模式 直接进入推拉流页
- if(ksharedAppDelegate.DeviceThirdIdMod && !ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode){
- ksharedAppDelegate.isCloudPhoneModeNotPrivacyModeOpenType = YES;
- [cloudVC queryWebRtcMsgFun:YES];
- }
- else{
- ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType = YES;
- }
-
- //tabBarController.selectedIndex = 1;
- }
-
- ksharedAppDelegate.mainTabBar = tabBarController;
- self.window.rootViewController = tabBarController;
- [self.window makeKeyAndVisible];
- }
- #pragma mark 处理进来是非隐私模式的情况
- - (void)HandleEnterNotPrivacyModeFun
- {
- #ifdef developJSQ
- NSInteger maskModel = 1;// [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
- #else
- NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
- #endif
- if (maskModel != 0){
- [HWDataManager setIntegerWithKey:Const_Mask_View_Model value:0];
- [iTools lc_setAlternateIconName:@"AppIcon1"];
- }
- }
- - (void)setPwdOk{
- [self enterMainVCFromScene];
-
- // NSArray *dataArray = [BaseModel bg_findAll:DB_BrowserWindows_TableName];
- //
- // if (dataArray.count == 0) { // 浏览器没有窗口
- // // 加载首页
- // HWWebViewController *vc = [[HWWebViewController alloc] init];
- // vc.webUrl = Const_HomeUrl;
- // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
- // self.window.rootViewController = nvc;
- //
- // }else {
- // // 浏览器当前窗口索引ID
- // NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
- // NSString *where = [NSString stringWithFormat:@"where %@=%ld",bg_sqlKey(@"ID"),(long)ID];
- // NSArray* finfAlls = [BaseModel bg_find:DB_BrowserWindows_TableName where:where];
- // BaseModel *model = finfAlls.firstObject;
- //
- // // 加载网页
- // HWWebViewController *vc = [[HWWebViewController alloc] init];
- // vc.webUrl = model.webUrl;
- // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
- // self.window.rootViewController = nvc;
- // }
- }
- /** 登录界面 - 外部使用*/
- + (void)enterLoginVC {
- // SetPWDViewController *vc = [[SetPWDViewController alloc] init];
- // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
- // UIWindow *keyWindow = [iTools getKeyWindow];
- // keyWindow.rootViewController = nvc;
- }
- /** 主界面 - 外部使用 */
- + (void)enterMainVC {
- // AlbumHomeViewController *vc = [[AlbumHomeViewController alloc] init];
- // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
- // UIWindow *keyWindow = [iTools getKeyWindow];
- // keyWindow.rootViewController = nvc;
- }
- - (void)sceneDidDisconnect:(UIScene *)scene API_AVAILABLE(ios(13.0)){
- HLog(@"sceneDidDisconnect");
-
- //[[connectDeviceManager shareInstance] disconnect];
- }
- - (void)sceneDidBecomeActive:(UIScene *)scene API_AVAILABLE(ios(13.0)){
- HLog(@"sceneDidBecomeActive")
- }
- - (void)sceneWillResignActive:(UIScene *)scene API_AVAILABLE(ios(13.0)){
- HLog(@"sceneWillResignActive")
-
- }
- - (void)sceneWillEnterForeground:(UIScene *)scene API_AVAILABLE(ios(13.0)){
- HLog(@"sceneWillEnterForeground")
-
- }
- - (void)sceneDidEnterBackground:(UIScene *)scene API_AVAILABLE(ios(13.0)){
- HLog(@"sceneDidEnterBackground")
-
- BOOL isPrivacyMode = [HWDataManager getBoolWithKey:Const_Have_Add_Device_Privacy_Mode];
-
- if(ksharedAppDelegate.DeviceThirdIdMod){
- isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
- }
-
- if(isPrivacyMode){//隐私模式 需要弹密码框 转竖屏
- BOOL isNeeddelayedType = NO;
- //这里强制竖屏 处理图片详情 和视频详情的横屏情况
- BaseNavigationController*mainNav = ksharedAppDelegate.mainTabBar.selectedViewController;
- if([mainNav isKindOfClass:[BaseNavigationController class]]){
- NSArray* vcArr = mainNav.viewControllers;
-
- if(vcArr.count >= 2){
- UIViewController *curVC = vcArr.lastObject;
-
- if([curVC isKindOfClass:[webRtcPlayerViewController class]]){
- webRtcPlayerViewController* vc = (webRtcPlayerViewController*)curVC;
- if(vc.isLan){
- ksharedAppDelegate.needToPushWebRtcVCType = YES;
- [vc exitCloudPhoneFun];
- }
- }
- else if([curVC isKindOfClass:[imageDetailsScrollViewController class]]
- ||[curVC isKindOfClass:[videoPlayByAVPlayerViewController class]]){
-
- //切换到竖屏
- ksharedAppDelegate.supportScreenRotateType = YES;
- [curVC hx_rotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
- //ksharedAppDelegate.supportScreenRotateType = NO;
- isNeeddelayedType = YES;
- HLog(@"sceneDidEnterBackground 旋转屏幕为竖屏")
- }
- }
- }
-
- [self showCalculatorVC];
- }
-
- }
- - (void)scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity {
- HLog(@"scene continueUserActivity")
- if([TencentOAuth CanHandleUniversalLink:userActivity.webpageURL]){
- [TencentOAuth HandleUniversalLink:userActivity.webpageURL];
- }
- else{
- [WXApi handleOpenUniversalLink:userActivity delegate:self];
- }
-
- }
- - (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts {
- HLog(@"scene openURLContexts")
- NSEnumerator *enumerator = [URLContexts objectEnumerator];
- UIOpenURLContext *context;
- while (context = [enumerator nextObject]) {
- NSLog(@"context.URL =====%@",context.URL);
- //openprivacyxapp://page?param1=value1¶m2=value2
- NSString *curStr = context.URL.absoluteString;
- if([curStr rangeOfString:@"openprivacyxapp://page"].location != NSNotFound){
- _getShareStr = curStr;
- [self delayedHandlShareAwakenAppBy:curStr];
- break;
- }
- else{
- [WXApi handleOpenURL:context.URL delegate:self];
- }
- //NSLog(@"context.options.sourceApplication ===== %@",context.options.sourceApplication);
-
- }
-
- _session = nil;
- _connectionOptions = nil;
- }
- - (void)delayedHandlShareAwakenAppBy:(NSString*)curStr{
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self shareAwakenAppBy:curStr];
- });
-
- }
- #pragma mark 初始化数据库-DB_BrowserWindows_TableName
- - (void)initBrowserWindow {
-
- // 浏览器当前所有窗口
- NSArray *dataArray = [BaseModel bg_findAll:DB_BrowserWindows_TableName];
- // 浏览器当前窗口索引ID
- NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
- NSString *IDValue = [NSString stringWithFormat:@"%ld", ID];
- NSString *where = [NSString stringWithFormat:@"where %@=%@",bg_sqlKey(@"ID"),bg_sqlValue(IDValue)];
- NSArray *modelArr = [BaseModel bg_find:DB_BrowserWindows_TableName where:where];
-
- if (dataArray.count == 0) { // 浏览器没有窗口
-
- BaseModel *model = [[BaseModel alloc] init];
- model.ID = 0;
- model.name = @"主页";
- // model.iconFile = imageUrl;
- model.webUrl = Const_HomeUrl;
-
- // 写入数据库
- model.bg_tableName = DB_BrowserWindows_TableName;
- [model bg_saveOrUpdateAsync:^(BOOL isSuccess) {
- HLog(@"BaseModel写入:%@", isSuccess ? @"成功":@"失败");
- }];
-
- // 浏览器当前窗口索引ID
- [HWDataManager setIntegerWithKey:BrowserWindowsCurrentID value:0];
-
- }else if (modelArr.count == 0) { // 新建窗口
- BaseModel *model = [[BaseModel alloc] init];
- model.ID = ID;
- model.name = @"主页";
- // model.iconFile = imageUrl;
- model.webUrl = Const_HomeUrl;
-
- // 写入数据库
- model.bg_tableName = DB_BrowserWindows_TableName;
- [model bg_saveOrUpdateAsync:^(BOOL isSuccess) {
- HLog(@"BaseModel写入:%@", isSuccess ? @"成功":@"失败");
- }];
-
- }else { // 更新窗口数据
- // 浏览器当前窗口索引ID
- // NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
- //
- // BaseModel *model = [[BaseModel alloc] init];
- // model.ID = ID;
- // model.name = @"主页";
- //// model.iconFile = imageUrl;
- // model.webUrl = Const_HomeUrl;
- //
- // // 更新数据库
- // model.bg_tableName = DB_BrowserWindows_TableName;
- // [model bg_saveOrUpdateAsync:^(BOOL isSuccess) {
- // HLog(@"BaseModel更新: %@", isSuccess ? @"成功":@"失败");
- // }];
- }
- }
- #pragma mark 获取当前屏幕的截图
- //- (UIImage *)getScreenShotImage {
- // CGSize size = [UIScreen mainScreen].bounds.size;
- // CGFloat scale = [UIScreen mainScreen].scale;
- // UIGraphicsBeginImageContextWithOptions(size, YES, scale);
- // [self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
- // UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
- // UIGraphicsEndImageContext();
- // return image;
- //}
- #pragma mark 计算器伪装视图
- /*CalculatorViewController*/
- - (void)showCalculatorVC{
- HLog(@"showCalculatorVC 处理密码框弹出")
-
- if(SCREEN_W > SCREEN_H){
- HLog(@"showCalculatorVC 屏幕还是横屏状态")
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self showCalculatorVC];
- });
- return;
- }
-
- ksharedAppDelegate.supportScreenRotateType = NO;
-
-
- if(ksharedAppDelegate.getSystemPermissType){
- HLog(@"检测到获取系统全进入后台");
- return;
- }
-
- BOOL haveGuide = [HWDataManager getBoolWithKey:Const_Have_Show_Guide];
- if (haveGuide) {
- ;
- }else {
-
- return;
- }
-
- BOOL isPrivacyMode = [HWDataManager getBoolWithKey:Const_Have_Add_Device_Privacy_Mode];
-
- if(ksharedAppDelegate.DeviceThirdIdMod){
- isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
- }
-
- if(!isPrivacyMode){
- return;
- }
-
- //修复扫描已经有密码的合作 点击跳过因为网络弹框再次覆盖一次密码(需要输入两次密码)
- BaseNavigationController*curTopNav = (BaseNavigationController*)[iTools appRootViewController];
- if([curTopNav isKindOfClass:[BaseNavigationController class]]){
- NSArray *vcArr = [curTopNav viewControllers];
- if(vcArr && vcArr.count >0){
- UIViewController *lastVC = vcArr.lastObject;
- if([lastVC isKindOfClass:[inputPWDViewController class]]){
- return;
- }
- }
- }
-
- /*无有效时长直接返回不加载任何加密界面*/
- NSString *PwdStr = nil;
- NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
-
- //实时拿到的密码 (每次打开或者更换设备 通过SN重新拿)
- if(ksharedAppDelegate.DeviceThirdIdMod.data.password){
- NSString *curPwd = ksharedAppDelegate.DeviceThirdIdMod.data.password;
- NSString*desPwdStr = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY];
-
- if(desPwdStr){
- PwdStr = desPwdStr;
- }
- }
- else{
- //本地密码本地判断 密码改在服务器保持
- if ([[deviceDict allKeys] containsObject:Const_Have_Add_Device_PWD]){
- PwdStr = [deviceDict objectForKey:Const_Have_Add_Device_PWD];
- }
- }
-
- if (!PwdStr || [PwdStr isEqualToString:@""])
- {
- return;
- }
-
- // BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_Mask_View_Open];
- // if (!haveOpenMask){
- // //输入密码界面
- // [self closeCalculatorVC];
- // _inputVC = [[inputPWDViewController alloc] init];
- // [self.window addSubview:_inputVC.view];
- // return;
- // }
-
- BOOL haveVaildTime = [HWDataManager getBoolWithKey:Const_Have_No_VaildTime];
- if (haveVaildTime == YES){/*无有效时间*/
- return;
- }
-
- if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus != AFNetworkReachabilityStatusNotReachable)
- {
- if(!ksharedAppDelegate.DeviceThirdIdMod){
- return;
- }
-
- BOOL isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
- if(!isPrivacyMode)
- {
- ksharedAppDelegate.isFirstInputPwdDone = YES;
- [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
- return;
- }
- }
-
- #ifdef developJSQ
- NSInteger maskModel = 1;// [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
- #else
- NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
- #endif
- if (maskModel == 0){
- //输入密码界面
- [self closeCalculatorVC];
- _inputVC = [[inputPWDViewController alloc] init];
- [self.window addSubview:_inputVC.view];
- ksharedAppDelegate.isDidShowPwdType = YES;
- }
- else if (maskModel == 2){
- /*浏览器*/
- [self closeCalculatorVC];
- _webVC = [[HWWebViewController alloc] init];
- _webVC.pwd = PwdStr;
- _webVC.webUrl = @"https://baidu.com";
- [self.window addSubview:_webVC.view];
- ksharedAppDelegate.isDidShowPwdType = YES;
- }else{
- /*计算器*/
- [self closeCalculatorVC];
- _calculatorVC = [[CalculatorViewController alloc] init];
- _calculatorVC.pwd = PwdStr;
- [self.window addSubview:_calculatorVC.view];
- ksharedAppDelegate.isDidShowPwdType = YES;
- }
- [[NSNotificationCenter defaultCenter] postNotificationName:ShowPwdVCNotification object:nil];
- }
- - (void)closeCalculatorVC{
-
- ksharedAppDelegate.getSystemPermissType = NO;
-
- if (_calculatorVC){
- [_calculatorVC.view removeFromSuperview];
- }
-
- /*浏览器*/
- if (_webVC){
- [_webVC.view removeFromSuperview];
- }
-
- if(_inputVC){
- [_inputVC.view removeFromSuperview];
- }
- ksharedAppDelegate.isDidShowPwdType = NO;
-
- if(self->_session && self->_connectionOptions){
- [self scene:self->_session openURLContexts:self->_connectionOptions.URLContexts];
- }
- }
- - (NSString *)documentPathForAccount:(NSString *)account fileFolder:(NSString *)fileFolder {
-
- NSString *path = DocumentPath;
- if (account.length != 0) {
- path = [NSString stringWithFormat:@"%@/%@/",DocumentPath,account];
- }
-
- if ([fileFolder containsString:@"/"]) {
- NSString *path1 = [path stringByAppendingPathComponent:fileFolder];
- path1 = [path1 stringByDeletingLastPathComponent];
- NSError *error;
- if (![[NSFileManager defaultManager] fileExistsAtPath:path1]) {
- [[NSFileManager defaultManager] createDirectoryAtPath:path1 withIntermediateDirectories:YES attributes:nil error:&error];
- }
- }else{
- NSError *error;
- if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
- [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
- }
- }
-
- return [path stringByAppendingPathComponent:fileFolder];
- }
- - (void)startUseBtnBePressed{
- [self enterMainVCFromScene];
- // NSString *launchAppPWDPath = [self documentPathForAccount:@"" fileFolder:@"LaunchPWD"];
- // NSString *str = [[NSString alloc] initWithContentsOfFile:launchAppPWDPath encoding:(NSUTF8StringEncoding) error:nil];
- // if (!str || [str isEqualToString:@"0"])
- // {
- // SetUsePWDViewController *loginVC = [[SetUsePWDViewController alloc] init];
- // loginVC.delegate = self;
- // self.window.rootViewController = loginVC;
- //
- // return;
- // }
- //
- // NSArray *dataArray = [BaseModel bg_findAll:DB_BrowserWindows_TableName];
- //
- // if (dataArray.count == 0) { // 浏览器没有窗口
- // // 加载首页
- // HWWebViewController *vc = [[HWWebViewController alloc] init];
- // vc.webUrl = Const_HomeUrl;
- // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
- // self.window.rootViewController = nvc;
- //
- // }else {
- // // 浏览器当前窗口索引ID
- // NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
- // NSString *where = [NSString stringWithFormat:@"where %@=%ld",bg_sqlKey(@"ID"),(long)ID];
- // NSArray* finfAlls = [BaseModel bg_find:DB_BrowserWindows_TableName where:where];
- // BaseModel *model = finfAlls.firstObject;
- //
- // // 加载网页
- // HWWebViewController *vc = [[HWWebViewController alloc] init];
- // vc.webUrl = model.webUrl;
- // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
- // self.window.rootViewController = nvc;
- // }
- }
- - (void)loginOk{
- [self enterMainVCFromScene];
- }
- - (void)guideOk:(NSNotification*)not{
-
- NSString *object = not.object;
- if(object && [object isEqualToString:@"isLoginAgainType"]){
- self.isLoginAgainType = YES;
- }
-
- //clear下载和上传的已经获取的数据
- // [[uploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
- // [uploadFileManager shareInstance].databaseArr = [NSMutableArray new];
- // [uploadFileManager shareInstance].fileModelDataArr = [NSMutableArray new];
- // [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType = uploadStateWait;
-
- [[nasUploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
- [nasUploadFileManager shareInstance].databaseArr = nil;
-
- // [[downloadManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
- // [downloadManager shareInstance].databaseArr = [NSMutableArray new];
- // [downloadManager shareInstance].downLoadFileModelDataArr = [NSMutableArray new];
-
- [[nasDownloadFileManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
- [nasDownloadFileManager shareInstance].databaseArr = nil;
-
- //[[backupsFileManager shareInstance] suspendBackupsFileFun];
- [[nasBackupsManager shareInstance] suspendBackupsFileFun];
-
- //frp的下载
- [[customDownloadManager shareManager] suspendAllDownloadTask];
-
- NSString *uid =ksharedAppDelegate.DeviceThirdIdMod.data.sn;
- if(uid){
-
- }
- else{
- uid = @"";
- }
-
- [customDownloadManager shareManager].uid = uid;
-
- //盒子1音频在播放音乐,切换盒子2成功,仍在播放中
- [[DFPlayer sharedPlayer] df_deallocPlayer];
-
- [lastFileManager shareManager].uid = uid;
- [audioPlayListManager shareManager].uid = uid;
-
-
- [self enterMainVCFromScene];
- }
- #pragma mark 上报版本号信息
- -(void)reportVersionInfoFun
- {
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
-
- NSString *vers = [iPhone appVersion];
- if(vers){
- [paraDict setValue:vers forKey:@"iosClientVersionNumber"];
- }
-
- NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
- if (deviceDict && [[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
- NSString*snStr = deviceDict[Const_Have_Add_Device_SN];
- if(snStr){
- [paraDict setValue:snStr forKey:@"sn"];
- }
- else{
- return;
- }
- }
- else{
- return;;
- }
-
- // KWeakSelf
- [[netWorkManager shareInstance] CommonPostCallBackCode:reportVersionInfo Parameters:paraDict success:^(id _Nonnull responseObject) {
-
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- #pragma mark 获取NAS相关信息
- -(void)getNASMsgFun
- {
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
-
- NSString *SNStr = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
- if(SNStr){
- [paraDict setValue:SNStr forKey:@"sn"];
- }
- else{
- return;;
- }
-
- KWeakSelf
- [[netWorkManager shareInstance] CommonGetWithCallBackCode:getIpFun Parameters:paraDict success:^(id _Nonnull responseObject){
- NASMsgModel *model = [[NASMsgModel alloc] initWithDictionary:responseObject error:nil];
- if(model){
- ksharedAppDelegate.NASMsgMod = model;
- }
-
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- #pragma mark 主动上锁
- - (void)showLockViewFun:(NSNotification*)not
- {
- [self showCalculatorVC];
- }
- #pragma mark 进入设置密码
- //- (void)setPwdVCFun:(NSNotification*)not
- //{
- // _isNeedToShowSecretKey = YES;
- //}
- #pragma mark 忘记密码
- - (void)forgetPwdFun:(NSNotification*)not
- {
-
- /*忘记密码*/
- forgetPwdViewController *forgetPwdVC = [[forgetPwdViewController alloc] init];
- BaseNavigationController *forgetPwdVCNav = [[BaseNavigationController alloc] initWithRootViewController:forgetPwdVC];
- self.window.rootViewController = forgetPwdVCNav;
-
- }
- #pragma mark 忘记密码返回
- - (void)forgetPwdBackFun:(NSNotification*)not
- {
- // if(_preRootPlayerNav)
- // {
- // self.window.rootViewController = _preRootPlayerNav;
- // }
- // else{
- [self enterMainVCFromScene];
- //}
-
- [self showCalculatorVC];
- }
- #pragma mark 忘记密码设置密码完成
- - (void)forgetPwdDidSetPwdFun:(NSNotification*)not
- {
- // if(_preRootPlayerNav)
- // {
- // NSArray *vcArr = _preRootPlayerNav.viewControllers;
- // if(vcArr.count > 2){
- // [_preRootPlayerNav popToViewController:vcArr[1] animated:NO];
- // }
- // self.window.rootViewController = _preRootPlayerNav;
- // }
- // else{
- [self enterMainVCFromScene];
- //}
-
- [self closeCalculatorVC];
-
- ksharedAppDelegate.isFirstInputPwdDone = YES;
- }
- #pragma mark 扫码切换设备 scanChangeDeviceNotification
- - (void)scanChangeDeviceFun:(NSNotification*)not
- {
-
- //TipsQRCodeForChangeDeviceViewController *nextVC = [[TipsQRCodeForChangeDeviceViewController alloc] init];
- QRCodeScanForChangeDeviceViewController *nextVC = [[QRCodeScanForChangeDeviceViewController alloc] init];
- nextVC.isRootVCType = YES;
- BaseNavigationController *nextNav = [[BaseNavigationController alloc] initWithRootViewController:nextVC];
- self.window.rootViewController = nextNav;
-
- }
- #pragma mark 扫码切换设备点击返回
- - (void)scanChangeDeviceBackFun:(NSNotification*)not
- {
- // if(_preRootPlayerNav)
- // {
- // self.window.rootViewController = _preRootPlayerNav;
- // }
- // else{
- [self enterMainVCFromScene];
- //}
-
- [self showCalculatorVC];
- }
- #pragma mark 网络异常弹框
- -(void)showNetErrorAlertFun
- {
- NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
-
- if(maskModel !=0 && ksharedAppDelegate.isDidShowPwdType){
- return;
- }
-
- NSString *linkErrTip = NSLocalizedString(@"player_link_fail_tip_type9",nil);
- if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable){
- //linkErrTip = NSLocalizedString(@"player_link_fail_phone_Tips",nil);
- _isNeedToStopWork = YES;
- [self showNetErrorAlertType2Fun];
- return;
- }
-
- linkErrTip = [[NSString alloc] initWithFormat:@"[9]%@",linkErrTip];
-
- ComontAlretViewController *linkFailAlretVC= [[ComontAlretViewController alloc] initWithTiTle:nil
- msg:linkErrTip
- imageStr:nil
- cancelTitle:NSLocalizedString(@"single_sign_on_exit",nil)
- okTitle:NSLocalizedString(@"player_link_fail_tryAgain",nil) isOkBtnHighlight:YES
- didClickOk:^{
-
- //[self enterMainVCFromScene];
- } didClickCancel:^{
- exit(0);
- }];
-
- linkFailAlretVC.modalPresentationStyle = UIModalPresentationCustom;
-
- [self.window.rootViewController presentViewController:linkFailAlretVC animated:YES completion:^{
- linkFailAlretVC.view.superview.backgroundColor = [UIColor clearColor];
- }];
- }
- #pragma mark 网络异常弹框
- -(void)showNetErrorAlertType2Fun
- {
- if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable){
-
- NSString * linkErrTip = NSLocalizedString(@"netWork_error_tip_content",nil);
-
- ComontAlretViewController *linkFailAlretVC= [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"netWork_error_tip_title",nil)
- msg:linkErrTip
- imageStr:nil
- cancelTitle:NSLocalizedString(@"single_sign_on_exit",nil)
- okTitle:nil isOkBtnHighlight:NO
- didClickOk:^{
-
- //[self enterMainVCFromScene];
- } didClickCancel:^{
- exit(0);
- }];
-
- linkFailAlretVC.modalPresentationStyle = UIModalPresentationCustom;
-
- self.window.rootViewController = [UIViewController new];
- [self.window.rootViewController presentViewController:linkFailAlretVC animated:YES completion:^{
- linkFailAlretVC.view.superview.backgroundColor = [UIColor clearColor];
- }];
- }
-
- }
- - (void)gotoScanAginByThridMsgErrorFun:(NSInteger)errorCode
- {
- /*扫码界面*/
- TipsQRCodeViewController *qrCodeVC = [[TipsQRCodeViewController alloc] init];
- qrCodeVC.isNeedToShowAleatType = YES;
- qrCodeVC.getSNMsgcode = errorCode;
- BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
- self.window.rootViewController = qrCodeVCNav;
- }
- #pragma mark 分享页面唤醒APP
- - (void)shareAwakenAppBy:(NSString*)shareStr
- {
- //[[iToast makeText:shareStr] show];
-
- NSArray * paraArr = [shareStr componentsSeparatedByString:@"&"];
- if(!paraArr || paraArr.count==0){
- return;
- }
-
- //type=save和download
- NSString *type = nil;
- NSString *fileIds = nil;
- NSString *extractionCode = nil;
- NSString *token = nil;
-
- for (NSString*objectStr in paraArr) {
- if([objectStr rangeOfString:@"type"].location != NSNotFound){
- NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
- if(objectArr.count == 2){
- type = objectArr.lastObject;
- continue;
- }
- }
- else if([objectStr rangeOfString:@"fileIds"].location != NSNotFound){
- NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
- if(objectArr.count == 2){
- fileIds = objectArr.lastObject;
- continue;
- }
- }
- else if([objectStr rangeOfString:@"extractionCode"].location != NSNotFound){
- NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
- if(objectArr.count == 2){
- extractionCode = objectArr.lastObject;
- continue;
- }
- }
- else if([objectStr rangeOfString:@"token"].location != NSNotFound){
- NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
- if(objectArr.count == 2){
- token = objectArr.lastObject;
- continue;
- }
- }
- }
-
- if(!type || type.length ==0){
- HLog(@"分享 type 获取错误");
- return;
- }
-
- if(!fileIds || fileIds.length ==0){
- HLog(@"分享 fileIds 获取错误");
- return;
- }
-
- if(!token || token.length ==0){
- HLog(@"分享 token 获取错误");
- return;
- }
-
- [self getShareOneFileListFunByToken:token withFileIds:fileIds withExtractionCode:extractionCode withType:type];
- }
- #pragma mark 分享信息重新获取
- - (void)getShareOneFileListFunByToken:(NSString*)token withFileIds:(NSString*)fileIds withExtractionCode:(NSString*)extractionCode withType:(NSString*)type
- {
-
- NSMutableDictionary*paraDict = [NSMutableDictionary new];
- fileIds = [fileIds stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-
- NSData *jsonData = [fileIds dataUsingEncoding:NSUTF8StringEncoding];;
- NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
-
- HLog(@"jsonArray:%@",jsonArray)
-
- if(!jsonArray){
- return;
- }
-
- [paraDict setValue:token forKey:@"token"];
- [paraDict setValue:jsonArray forKey:@"fileIdList"];
- [paraDict setValue:extractionCode forKey:@"extractionCode"];
- KWeakSelf
- [[netWorkManager shareInstance] CommonPostCallBackCode:queryOneShareInfoFun Parameters:paraDict success:^(id _Nonnull responseObject) {
- queryOneShareModel*model = [[queryOneShareModel alloc] initWithDictionary:responseObject error:nil];
- if(model && model.status == 0){
- weakSelf.getShareStr = nil;
- [weakSelf gotoVCByModel:model withType:type];
- }
- else{
- }
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- #pragma mark 跳转
- - (void)gotoVCByModel:(queryOneShareModel*)model withType:(NSString*)type
- {
- if([type isEqualToString:@"save"]){
- [self saveFileToBoxFunBy:model];
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Share_save"];
- }
- else if([type isEqualToString:@"download"]){
- [self downloadFileToAppFunBy:model];
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Share_download"];
- }
-
-
- }
- #pragma mark 保存文件到盒子
- - (void)saveFileToBoxFunBy:(queryOneShareModel*)sharemodel
- {
- NSMutableDictionary*paraDict = [NSMutableDictionary new];
-
- NSMutableArray *pathArr = [NSMutableArray new];
-
- for (ShareFileDataModel*dataModel in sharemodel.data.fileListVOS){
- [pathArr addObject:dataModel.fileUrl];
- }
-
- if (pathArr) {
- NSString *jsonStr = [iTools toJsonStrWithArray:pathArr];
- if(jsonStr){
- [paraDict setValue:jsonStr forKey:@"urls"];
- }
- }
-
-
- NSString * boxSaveDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_box_save_default_path)];
-
- if(!boxSaveDefaultPath || boxSaveDefaultPath.length == 0){
- boxSaveDefaultPath = Const_default_save_path;
- [HWDataManager setStringWithKey:stringKeyAddSn(Const_box_save_default_path) value:boxSaveDefaultPath];
- }
-
- [paraDict setValue:boxSaveDefaultPath forKey:@"savePath"];
-
- KWeakSelf
- [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"downFiles" Parameters:paraDict success:^(id _Nonnull responseObject) {
-
- SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
- if(model && model.status == 0){
- [weakSelf gotoUploadFileRecordVCFunByType:2 withModel:sharemodel];
- }
- } failure:^(NSError * _Nonnull error) {
-
- }];
- }
- #pragma mark 下载文件到手机
- - (void)downloadFileToAppFunBy:(queryOneShareModel*)sharemodel
- {
- [self gotoUploadFileRecordVCFunByType:1 withModel:sharemodel];
- }
- #pragma mark 跳转传输列表
- - (void)gotoUploadFileRecordVCFunByType:(NSInteger)type withModel:(queryOneShareModel*)sharemodel
- {
- KWeakSelf
- if(type == 2){
- [[boxSaveFileManager shareInstance] addBoxSaveRecordFunBy:sharemodel.data.fileListVOS complete:^(BOOL isSuccess) {
- if(isSuccess){
- mainBlock(^{
- [weakSelf gotoUploadFileRecordVCFunByType:type];
- });
-
- }
- }];
- }
- else if (type == 1){
- if(![iTools checkFreeDiskSpaceInBytesIsOK:500*1024*1024]){
- mainBlock(^{
- [[iToast makeText:NSLocalizedString(@"phone_space_Insufficient",nil)] show];
- });
- return;
- }
- [[boxDownloadFileManager shareInstance] addBoxDownloadRecordFunBy:sharemodel.data.fileListVOS complete:^(BOOL isSuccess) {
- if(isSuccess){
- mainBlock(^{
- [weakSelf gotoUploadFileRecordVCFunByType:type];
- });
-
- }
- }];
- }
-
-
- }
- - (void)gotoUploadFileRecordVCFunByType:(NSInteger)type
- {
- uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
- vc.isReceiveType = type;
-
- BaseNavigationController*mainNav = ksharedAppDelegate.mainTabBar.selectedViewController;
-
- if([mainNav isKindOfClass:[BaseNavigationController class]]){
- [mainNav pushViewController:vc animated:YES];
- [[UIApplication sharedApplication] setStatusBarHidden:NO];
- }
- }
- #pragma mark UITabBarControllerDelegate
- - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
- {
- NSInteger index = tabBarController.selectedIndex;
-
- int eventType = 1;
- NSString* eventValue = @"Nas";
- if(index == 0){
- eventValue = @"Nas";
- }
- else if(index == 1){
- eventValue = @"Cloud";
- }
- else if(index == 2){
- eventValue = @"Home";
- }
-
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:eventType withEventValue:eventValue];
-
- }
- - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
- {
- if(ksharedAppDelegate.isCloudPhoneModeNotPrivacyModeOpenType
- || ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType){
- return NO;
- }
- return YES;
- }
- @end
|