Initial commit
This commit is contained in:
@ -0,0 +1,39 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "OCTFileStorageProtocol.h"
|
||||
|
||||
/**
|
||||
* Default storage for files. It has following directory structure:
|
||||
* /baseDirectory/saveFileName.tox - tox save file name. You can specify it in appropriate method.
|
||||
* /baseDirectory/database - database with chats, messages and related stuff.
|
||||
* /baseDirectory/database.encryptionkey - encryption key for database.
|
||||
* /baseDirectory/files/ - downloaded and uploaded files will be stored here.
|
||||
* /baseDirectory/avatars/ - avatars will be stored here.
|
||||
* /temporaryDirectory/ - temporary files will be stored here.
|
||||
*/
|
||||
@interface OCTDefaultFileStorage : NSObject <OCTFileStorageProtocol>
|
||||
|
||||
/**
|
||||
* Creates default file storage. Will use "save.tox" as default save file name.
|
||||
*
|
||||
* @param baseDirectory Base directory to use. It will have "files", "avatars" subdirectories.
|
||||
* @param temporaryDirectory All temporary files will be stored here. You can pass NSTemporaryDirectory() here.
|
||||
*/
|
||||
- (instancetype)initWithBaseDirectory:(NSString *)baseDirectory temporaryDirectory:(NSString *)temporaryDirectory;
|
||||
|
||||
/**
|
||||
* Creates default file storage.
|
||||
*
|
||||
* @param saveFileName Name of file to store tox save data. ".tox" extension will be appended to the name.
|
||||
* @param baseDirectory Base directory to use. It will have "files", "avatars" subdirectories.
|
||||
* @param temporaryDirectory All temporary files will be stored here. You can pass NSTemporaryDirectory() here.
|
||||
*/
|
||||
- (instancetype)initWithToxSaveFileName:(NSString *)saveFileName
|
||||
baseDirectory:(NSString *)baseDirectory
|
||||
temporaryDirectory:(NSString *)temporaryDirectory;
|
||||
|
||||
@end
|
@ -0,0 +1,66 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol OCTFileStorageProtocol <NSObject>
|
||||
|
||||
@required
|
||||
|
||||
/**
|
||||
* Returns path where tox save data will be stored. Save file should have ".tox" extension.
|
||||
* See Tox STS for more information: https://github.com/Tox/Tox-STS
|
||||
*
|
||||
* @return Full path to the file for loading/saving tox data.
|
||||
*
|
||||
* @warning Path should be file path. The file can be rewritten at any time while OCTManager is alive.
|
||||
*/
|
||||
@property (readonly) NSString *pathForToxSaveFile;
|
||||
|
||||
/**
|
||||
* Returns file path for database to be stored in. Must be a file path, not directory.
|
||||
* In database will be stored chats, messages and related stuff.
|
||||
*
|
||||
* @return Full path to the file for the database.
|
||||
*
|
||||
* @warning Path should be file path. The file can be rewritten at any time while OCTManager is alive.
|
||||
*/
|
||||
@property (readonly) NSString *pathForDatabase;
|
||||
|
||||
/**
|
||||
* Returns file path for database encryption key to be stored in. Must be a file path, not a directory.
|
||||
*
|
||||
* @return Full path to the file to store database encryption key.
|
||||
*
|
||||
* @warning Path should be file path. The file can be rewritten at any time while OCTManager is alive.
|
||||
*/
|
||||
@property (readonly) NSString *pathForDatabaseEncryptionKey;
|
||||
|
||||
/**
|
||||
* Returns path where all downloaded files will be stored.
|
||||
*
|
||||
* @return Full path to the directory with downloaded files.
|
||||
*/
|
||||
@property (readonly) NSString *pathForDownloadedFilesDirectory;
|
||||
|
||||
/**
|
||||
* Returns path where all uploaded files will be stored.
|
||||
*
|
||||
* @return Full path to the directory with uploaded files.
|
||||
*/
|
||||
@property (readonly) NSString *pathForUploadedFilesDirectory;
|
||||
|
||||
/**
|
||||
* Returns path where temporary files will be stored. This directory can be cleaned on relaunch of app.
|
||||
* You can use NSTemporaryDirectory() here.
|
||||
*
|
||||
* @return Full path to the directory with temporary files.
|
||||
*/
|
||||
@property (readonly) NSString *pathForTemporaryFilesDirectory;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@ -0,0 +1,60 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "OCTFileStorageProtocol.h"
|
||||
#import "OCTToxOptions.h"
|
||||
|
||||
/**
|
||||
* Configuration for OCTManager.
|
||||
*/
|
||||
@interface OCTManagerConfiguration : NSObject <NSCopying>
|
||||
|
||||
/**
|
||||
* File storage to use.
|
||||
*
|
||||
* Default values: OCTDefaultFileStorage will be used with following parameters:
|
||||
* - tox save file is stored at "{app document directory}/me.dvor.objcTox/save.tox"
|
||||
* - database file is stored at "{app document directory}/me.dvor.objcTox/database"
|
||||
* - database encryption key file is stored at "{app document directory}/me.dvor.objcTox/database.encryptionkey"
|
||||
* - downloaded files are stored at "{app document directory}/me.dvor.objcTox/downloads"
|
||||
* - uploaded files are stored at "{app document directory}/me.dvor.objcTox/uploads"
|
||||
* - avatars are stored at "{app document directory}/me.dvor.objcTox/avatars"
|
||||
* - temporary files are stored at NSTemporaryDirectory()
|
||||
*/
|
||||
@property (strong, nonatomic, nonnull) id<OCTFileStorageProtocol> fileStorage;
|
||||
|
||||
/**
|
||||
* Options for tox to use.
|
||||
*/
|
||||
@property (strong, nonatomic, nonnull) OCTToxOptions *options;
|
||||
|
||||
/**
|
||||
* If this parameter is set, tox save file will be copied from given path.
|
||||
* You can set this property to import tox save from some other location.
|
||||
*
|
||||
* Default value: nil.
|
||||
*/
|
||||
@property (strong, nonatomic, nullable) NSString *importToxSaveFromPath;
|
||||
|
||||
/**
|
||||
* When faux offline messaging is enabled, it is allowed to send message to
|
||||
* offline friends. In that case message would be stored in database and resend
|
||||
* when friend comes online.
|
||||
*
|
||||
* Default value: YES.
|
||||
*/
|
||||
@property (assign, nonatomic) BOOL useFauxOfflineMessaging;
|
||||
|
||||
/**
|
||||
* This is default configuration for manager.
|
||||
* Each property of OCTManagerConfiguration has "Default value" field. This method returns configuration
|
||||
* with those default values set.
|
||||
*
|
||||
* @return Default configuration for OCTManager.
|
||||
*/
|
||||
+ (nonnull instancetype)defaultConfiguration;
|
||||
|
||||
@end
|
Reference in New Issue
Block a user