123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- //
- // KMCloudServer.h
- // PDF Reader
- //
- // Created by wanjun on 2020/7/16.
- // Copyright © 2020 Kdan Mobile. All rights reserved.
- //
- #import <Foundation/Foundation.h>
- #import <AppKit/AppKit.h>
- #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<KMServicesCloudFile *> *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<KMCloudOperation *> *operationArr;
- NSMutableArray<KMServicesCloudFile *> *DropboxLocalFileList;
- NSMutableArray<KMServicesCloudFile *> *GoogleDriveLocalFileList;
- }
- @property (nonatomic, strong) NSMutableArray<KMServicesCloudFile *> *DropboxLocalFileList; //获取当前的文件列表
- @property (nonatomic, strong) NSMutableArray<KMServicesCloudFile *> *GoogleDriveLocalFileList; //获取当前的文件列表
- @property (nonatomic, strong) NSMutableArray<KMCloudOperation *> *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 <KMCloudServer *>*)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<KMCloudOperation *> *) operations;
- - (KMServicesCloudFile *)cloudFolderCacheForDisPath:(NSString *)path;
- - (KMServicesCloudFile *)getUpperPathCloudFolder:(KMServicesCloudFile *)file;
- @end
- @interface KMCloudServer (Additions)
- + (BOOL)networkConnectionStatusOnceAlertWhileNetworkNotReachable;
- + (BOOL)networkConnectionStatusForAdjectiveFunctionAlertWhileNetworkNotReachable;
- @end
|