// // KMCloudServer.h // PDF Reader // // Created by wanjun on 2020/7/16. // Copyright © 2020 Kdan Mobile. All rights reserved. // #import #import #import "KMServicesCloudFile.h" #import "GTLRDrive.h" #define KMBoxName @"Box" #define KMDropboxName @"Dropbox" extern NSString *const KMServerCloudFileManagerDownloadStateChangeNotification; extern NSString *const KMServerCloudFileManagerDownloadSuccessfulNotification; extern NSString *const KMServerCloudFileManagerDownloadFailureNotification; extern NSString *const KMServerCloudFileManagerUploadSuccessfulNotification; extern NSString *const KMServerCloudFileManagerUploadFailureNotification; typedef enum { KMNone = 0, KMDropbox , KMGoogleDrive , }KMServerType; typedef void(^CloudLoginCallBack)(id cloudFile, BOOL finished); typedef void(^CloudLogoutCallBack)(BOOL finished); typedef void(^CloudDeleteFileCallBack)(KMServicesCloudFile *cloudFile, BOOL finished); typedef void(^CreateFolderCallBack)(KMServicesCloudFile *cloudFile, BOOL finished); typedef void(^GetFileListCallBack)(NSArray *fileList,KMServerType serviceType,NSError *error); typedef void(^CurrentProgressCallBack)(KMServicesCloudFile *cloudFile,CGFloat loadProgress); typedef void(^CompletionCallBack)(KMServicesCloudFile *cloudFile,BOOL finished); @class KMCloudOperation; @interface KMCloudServer : NSObject { NSMutableArray *operationArr; NSMutableArray *DropboxLocalFileList; NSMutableArray *GoogleDriveLocalFileList; } @property (nonatomic, strong) NSMutableArray *DropboxLocalFileList; //获取当前的文件列表 @property (nonatomic, strong) NSMutableArray *GoogleDriveLocalFileList; //获取当前的文件列表 @property (nonatomic, strong) NSMutableArray *operationArr; @property (nonatomic, readonly) KMServicesCloudFile *localRootFolder;//获取本读根文件夹 @property (nonatomic, assign) KMServerType serverType; @property (nonatomic, assign) NSInteger index; @property (nonatomic, copy) NSString *accountId; @property (nonatomic, copy) NSString *userEmail; /** Retrieve all logged-in cloud services objects @return Return an array fo KMServerType objects */ + (NSArray *)getAllLoginServer; + (BOOL)networkConnectionStatus; + (BOOL)isConnectionAvailable; /** First run time Settings Server type. @param type Server type. */ - (id) initCloudWithServerType:(KMServerType)type; /** Cloud Whether to login. */ - (BOOL)isSignedIn; /** Cloud auth/login. */ - (void) authorizedLoginCompletion:(CloudLoginCallBack)completion; /** Cloud logout. */ - (void) authorizedLogoutCompletion:(CloudLogoutCallBack)completion; /** Upload local content to Cloud cloud disk space. @param cloudPath Cloud cloud disk space. @param localPath local file path url. @return upload operation. */ - (KMCloudOperation *)uploadCloudPath:(KMServicesCloudFile *)cloudPath localPath:(NSURL *)localPath currentConvetProgress:(CurrentProgressCallBack)currentProgress completion:(CompletionCallBack)completion; /** Cloud cancel upload operation. @param operation upload operation */ - (void) uploadCancel:(KMCloudOperation *)operation; /** Download files from Cloud cloud disk to local space. @param cloudPath Cloud cloud disk space. @param localPath local space path url. @return download operation. */ - (KMCloudOperation *)downloadCloudPath:(KMServicesCloudFile *)cloudPath localPath:(NSURL *)localPath currentConvetProgress:(CurrentProgressCallBack)currentProgress completion:(CompletionCallBack)completion; /** Cloud cancel download operation. @param operation download operation */ - (void) downloadCancel:(KMCloudOperation *)operation; /** Delete Cloud file based on file object. @param fileData Cloud file metadata */ -(void) deleteFileWithPath:(KMServicesCloudFile *)fileData completion:(CloudDeleteFileCallBack)completion; /** Create Cloud folder based on file object. @param fileData Cloud file metadata. @param folderName Created folder name. */ -(void) createFolderWithPath:(KMServicesCloudFile * )fileData folderName:(NSString *)folderName completion:(CreateFolderCallBack)completion; /** Get Cloud file list based on file object. @param fileData Cloud file metadata. Root folder is 'localRootFolder' @param responseBlock succeed block */ - (void)getListWithFilePath:(KMServicesCloudFile *)fileData setResponseBlock:(GetFileListCallBack)responseBlock; - (NSArray *) operations; - (KMServicesCloudFile *)cloudFolderCacheForDisPath:(NSString *)path; - (KMServicesCloudFile *)getUpperPathCloudFolder:(KMServicesCloudFile *)file; @end @interface KMCloudServer (Additions) + (BOOL)networkConnectionStatusOnceAlertWhileNetworkNotReachable; + (BOOL)networkConnectionStatusForAdjectiveFunctionAlertWhileNetworkNotReachable; @end