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
|
95
local_pod_repo/objcTox/Classes/Public/Manager/OCTManager.h
Normal file
95
local_pod_repo/objcTox/Classes/Public/Manager/OCTManager.h
Normal file
@ -0,0 +1,95 @@
|
||||
// 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 "OCTToxConstants.h"
|
||||
#import "OCTManagerConstants.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class OCTManagerConfiguration;
|
||||
|
||||
@protocol OCTSubmanagerBootstrap;
|
||||
@protocol OCTSubmanagerCalls;
|
||||
@protocol OCTSubmanagerChats;
|
||||
@protocol OCTSubmanagerFiles;
|
||||
@protocol OCTSubmanagerFriends;
|
||||
@protocol OCTSubmanagerObjects;
|
||||
@protocol OCTSubmanagerUser;
|
||||
|
||||
@protocol OCTManager <NSObject>
|
||||
|
||||
/**
|
||||
* Submanager responsible for connecting to other nodes.
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) id<OCTSubmanagerBootstrap> bootstrap;
|
||||
|
||||
/**
|
||||
* Submanager with all video/calling methods.
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) id<OCTSubmanagerCalls> calls;
|
||||
|
||||
/**
|
||||
* Submanager with all chats methods.
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) id<OCTSubmanagerChats> chats;
|
||||
|
||||
/**
|
||||
* Submanager with all files methods.
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) id<OCTSubmanagerFiles> files;
|
||||
|
||||
/**
|
||||
* Submanager with all friends methods.
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) id<OCTSubmanagerFriends> friends;
|
||||
|
||||
/**
|
||||
* Submanager with all objects methods.
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) id<OCTSubmanagerObjects> objects;
|
||||
|
||||
/**
|
||||
* Submanager with all user methods.
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) id<OCTSubmanagerUser> user;
|
||||
|
||||
/**
|
||||
* Configuration used by OCTManager.
|
||||
*
|
||||
* @return Copy of configuration used by manager.
|
||||
*/
|
||||
- (OCTManagerConfiguration *)configuration;
|
||||
|
||||
/**
|
||||
* Copies tox save file to temporary directory and return path to it.
|
||||
*
|
||||
* @param error NSFileManager error in case if file cannot be copied.
|
||||
*
|
||||
* @return Temporary path of current tox save file.
|
||||
*/
|
||||
- (nullable NSString *)exportToxSaveFileAndReturnError:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* Set password to encrypt tox save file and database.
|
||||
*
|
||||
* @param newPassword New password used to encrypt tox save file and database.
|
||||
* @param oldPassword Old password.
|
||||
*
|
||||
* @return YES on success, NO on failure (if old password doesn't match).
|
||||
*/
|
||||
- (BOOL)changeEncryptPassword:(nonnull NSString *)newPassword oldPassword:(nonnull NSString *)oldPassword;
|
||||
|
||||
/**
|
||||
* Checks if manager is encrypted with given password.
|
||||
*
|
||||
* @param password Password to verify.
|
||||
*
|
||||
* @return YES if manager is encrypted with given password, NO otherwise.
|
||||
*/
|
||||
- (BOOL)isManagerEncryptedWithPassword:(nonnull NSString *)password;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@ -0,0 +1,326 @@
|
||||
// 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 "OCTToxConstants.h"
|
||||
|
||||
/**
|
||||
* Maximum avatar size as defined in
|
||||
* https://tox.gitbooks.io/tox-client-standard/content/user_identification/avatar.html
|
||||
*/
|
||||
static const OCTToxFileSize kOCTManagerMaxAvatarSize = 65536;
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTFetchRequestType) {
|
||||
OCTFetchRequestTypeFriend,
|
||||
OCTFetchRequestTypeFriendRequest,
|
||||
OCTFetchRequestTypeChat,
|
||||
OCTFetchRequestTypeCall,
|
||||
OCTFetchRequestTypeMessageAbstract,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTMessageFileType) {
|
||||
/**
|
||||
* File is incoming and is waiting confirmation of user to be downloaded.
|
||||
* Please start loading or cancel it with <<placeholder>> method.
|
||||
*/
|
||||
OCTMessageFileTypeWaitingConfirmation,
|
||||
|
||||
/**
|
||||
* File is downloading or uploading.
|
||||
*/
|
||||
OCTMessageFileTypeLoading,
|
||||
|
||||
/**
|
||||
* Downloading or uploading of file is paused.
|
||||
*/
|
||||
OCTMessageFileTypePaused,
|
||||
|
||||
/**
|
||||
* Downloading or uploading of file was canceled.
|
||||
*/
|
||||
OCTMessageFileTypeCanceled,
|
||||
|
||||
/**
|
||||
* File is fully loaded.
|
||||
* In case of incoming file now it can be shown to user.
|
||||
*/
|
||||
OCTMessageFileTypeReady,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTMessageFilePausedBy) {
|
||||
/**
|
||||
* File transfer isn't paused.
|
||||
*/
|
||||
OCTMessageFilePausedByNone = 0,
|
||||
|
||||
/**
|
||||
* File transfer is paused by user.
|
||||
*/
|
||||
OCTMessageFilePausedByUser = 1 << 0,
|
||||
|
||||
/**
|
||||
* File transfer is paused by friend.
|
||||
*/
|
||||
OCTMessageFilePausedByFriend = 1 << 1,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTMessageCallEvent) {
|
||||
/**
|
||||
* Call was answered.
|
||||
*/
|
||||
OCTMessageCallEventAnswered,
|
||||
|
||||
/**
|
||||
* Call was unanswered.
|
||||
*/
|
||||
OCTMessageCallEventUnanswered,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTCallStatus) {
|
||||
/**
|
||||
* Call is currently ringing.
|
||||
*/
|
||||
OCTCallStatusRinging,
|
||||
|
||||
/**
|
||||
* Call is currently dialing a chat.
|
||||
*/
|
||||
OCTCallStatusDialing,
|
||||
|
||||
/**
|
||||
* Call is currently active in session.
|
||||
*/
|
||||
OCTCallStatusActive,
|
||||
};
|
||||
|
||||
typedef NS_OPTIONS(NSInteger, OCTCallPausedStatus) {
|
||||
/**
|
||||
* Call is not paused
|
||||
*/
|
||||
OCTCallPausedStatusNone = 0,
|
||||
|
||||
/**
|
||||
* Call is paused by the user
|
||||
*/
|
||||
OCTCallPausedStatusByUser = 1 << 0,
|
||||
|
||||
/**
|
||||
* Call is paused by friend
|
||||
*/
|
||||
OCTCallPausedStatusByFriend = 1 << 1,
|
||||
};
|
||||
|
||||
extern NSString *const kOCTManagerErrorDomain;
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTManagerInitError) {
|
||||
/**
|
||||
* Cannot create symmetric key from given passphrase.
|
||||
*/
|
||||
OCTManagerInitErrorPassphraseFailed,
|
||||
|
||||
/** ---------------------------------------- */
|
||||
|
||||
/**
|
||||
* Cannot copy tox save at `importToxSaveFromPath` path.
|
||||
*/
|
||||
OCTManagerInitErrorCannotImportToxSave,
|
||||
|
||||
/** ---------------------------------------- */
|
||||
|
||||
/**
|
||||
* Cannot create encryption key.
|
||||
*/
|
||||
OCTManagerInitErrorDatabaseKeyCannotCreateKey,
|
||||
|
||||
/**
|
||||
* Cannot read encryption key.
|
||||
*/
|
||||
OCTManagerInitErrorDatabaseKeyCannotReadKey,
|
||||
|
||||
/**
|
||||
* Old unencrypted database was found and migration attempt was made. However migration failed for some reason.
|
||||
*
|
||||
* You can check NSLocalizedDescriptionKey and NSLocalizedFailureReasonErrorKey for more info.
|
||||
*/
|
||||
OCTManagerInitErrorDatabaseKeyMigrationToEncryptedFailed,
|
||||
|
||||
/**
|
||||
* Cannot decrypt database key file.
|
||||
* Some input data was empty.
|
||||
*/
|
||||
OCTManagerInitErrorDatabaseKeyDecryptNull,
|
||||
|
||||
/**
|
||||
* Cannot decrypt database key file.
|
||||
* The input data is missing the magic number (i.e. wasn't created by this module, or is corrupted).
|
||||
*/
|
||||
OCTManagerInitErrorDatabaseKeyDecryptBadFormat,
|
||||
|
||||
/**
|
||||
* Cannot decrypt database key file.
|
||||
* The encrypted byte array could not be decrypted. Either the data was corrupt or the password/key was incorrect.
|
||||
*/
|
||||
OCTManagerInitErrorDatabaseKeyDecryptFailed,
|
||||
|
||||
/** ---------------------------------------- */
|
||||
|
||||
/**
|
||||
* Cannot decrypt tox save file.
|
||||
* Some input data was empty.
|
||||
*/
|
||||
OCTManagerInitErrorToxFileDecryptNull,
|
||||
|
||||
/**
|
||||
* Cannot decrypt tox save file.
|
||||
* The input data is missing the magic number (i.e. wasn't created by this module, or is corrupted).
|
||||
*/
|
||||
OCTManagerInitErrorToxFileDecryptBadFormat,
|
||||
|
||||
/**
|
||||
* Cannot decrypt tox save file.
|
||||
* The encrypted byte array could not be decrypted. Either the data was corrupt or the password/key was incorrect.
|
||||
*/
|
||||
OCTManagerInitErrorToxFileDecryptFailed,
|
||||
|
||||
/** ---------------------------------------- */
|
||||
|
||||
/**
|
||||
* Cannot create tox.
|
||||
* Unknown error occurred.
|
||||
*/
|
||||
OCTManagerInitErrorCreateToxUnknown,
|
||||
|
||||
/**
|
||||
* Cannot create tox.
|
||||
* Was unable to allocate enough memory to store the internal structures for the Tox object.
|
||||
*/
|
||||
OCTManagerInitErrorCreateToxMemoryError,
|
||||
|
||||
/**
|
||||
* Cannot create tox.
|
||||
* Was unable to bind to a port. This may mean that all ports have already been bound,
|
||||
* e.g. by other Tox instances, or it may mean a permission error.
|
||||
*/
|
||||
OCTManagerInitErrorCreateToxPortAlloc,
|
||||
|
||||
/**
|
||||
* Cannot create tox.
|
||||
* proxyType was invalid.
|
||||
*/
|
||||
OCTManagerInitErrorCreateToxProxyBadType,
|
||||
|
||||
/**
|
||||
* Cannot create tox.
|
||||
* proxyAddress had an invalid format or was nil (while proxyType was set).
|
||||
*/
|
||||
OCTManagerInitErrorCreateToxProxyBadHost,
|
||||
|
||||
/**
|
||||
* Cannot create tox.
|
||||
* proxyPort was invalid.
|
||||
*/
|
||||
OCTManagerInitErrorCreateToxProxyBadPort,
|
||||
|
||||
/**
|
||||
* Cannot create tox.
|
||||
* The proxy host passed could not be resolved.
|
||||
*/
|
||||
OCTManagerInitErrorCreateToxProxyNotFound,
|
||||
|
||||
/**
|
||||
* Cannot create tox.
|
||||
* The saved data to be loaded contained an encrypted save.
|
||||
*/
|
||||
OCTManagerInitErrorCreateToxEncrypted,
|
||||
|
||||
/**
|
||||
* Cannot create tox.
|
||||
* The data format was invalid. This can happen when loading data that was
|
||||
* saved by an older version of Tox, or when the data has been corrupted.
|
||||
* When loading from badly formatted data, some data may have been loaded,
|
||||
* and the rest is discarded. Passing an invalid length parameter also
|
||||
* causes this error.
|
||||
*/
|
||||
OCTManagerInitErrorCreateToxBadFormat,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTSetUserAvatarError) {
|
||||
/**
|
||||
* User avatar size is too big. It should be <= kOCTManagerMaxAvatarSize.
|
||||
*/
|
||||
OCTSetUserAvatarErrorTooBig,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTSendFileError) {
|
||||
/**
|
||||
* Internal error occured while sending file.
|
||||
* Check logs for more info.
|
||||
*/
|
||||
OCTSendFileErrorInternalError,
|
||||
|
||||
/**
|
||||
* Cannot read file.
|
||||
*/
|
||||
OCTSendFileErrorCannotReadFile,
|
||||
|
||||
/**
|
||||
* Cannot save send file to uploads folder.
|
||||
*/
|
||||
OCTSendFileErrorCannotSaveFileToUploads,
|
||||
|
||||
/**
|
||||
* Friend to send file to was not found.
|
||||
*/
|
||||
OCTSendFileErrorFriendNotFound,
|
||||
|
||||
/**
|
||||
* Friend is not connected at the moment.
|
||||
*/
|
||||
OCTSendFileErrorFriendNotConnected,
|
||||
|
||||
/**
|
||||
* Filename length exceeded kOCTToxMaxFileNameLength bytes.
|
||||
*/
|
||||
OCTSendFileErrorNameTooLong,
|
||||
|
||||
/**
|
||||
* Too many ongoing transfers. The maximum number of concurrent file transfers
|
||||
* is 256 per friend per direction (sending and receiving).
|
||||
*/
|
||||
OCTSendFileErrorTooMany,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTAcceptFileError) {
|
||||
/**
|
||||
* Internal error occured while sending file.
|
||||
* Check logs for more info.
|
||||
*/
|
||||
OCTAcceptFileErrorInternalError,
|
||||
|
||||
/**
|
||||
* File is not available for writing.
|
||||
*/
|
||||
OCTAcceptFileErrorCannotWriteToFile,
|
||||
|
||||
/**
|
||||
* Friend to send file to was not found.
|
||||
*/
|
||||
OCTAcceptFileErrorFriendNotFound,
|
||||
|
||||
/**
|
||||
* Friend is not connected at the moment.
|
||||
*/
|
||||
OCTAcceptFileErrorFriendNotConnected,
|
||||
|
||||
/**
|
||||
* Wrong message specified (with no friend, no file or not waiting for confirmation).
|
||||
*/
|
||||
OCTAcceptFileErrorWrongMessage,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTFileTransferError) {
|
||||
/**
|
||||
* Wrong message specified (with no file).
|
||||
*/
|
||||
OCTFileTransferErrorWrongMessage,
|
||||
};
|
@ -0,0 +1,35 @@
|
||||
// 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
|
||||
|
||||
@class OCTManagerConfiguration;
|
||||
@protocol OCTManager;
|
||||
|
||||
@interface OCTManagerFactory : NSObject
|
||||
|
||||
/**
|
||||
* Create manager with configuration. There is no way to change configuration after init method. If you'd like to
|
||||
* change it you have to recreate OCTManager.
|
||||
*
|
||||
* @param configuration Configuration to be used.
|
||||
* @param encryptPassword Password used to encrypt/decrypt tox save file and database.
|
||||
* Tox file will be encrypted automatically if it wasn't encrypted before.
|
||||
* @param successBlock Block called on success with initialized OCTManager. Will be called on main thread.
|
||||
* @param failureBlock Block called on failure. Will be called on main thread.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTManagerInitError for all error codes.
|
||||
*
|
||||
* @warning This method should be called on main thread.
|
||||
*/
|
||||
+ (void)managerWithConfiguration:(OCTManagerConfiguration *)configuration
|
||||
encryptPassword:(NSString *)encryptPassword
|
||||
successBlock:(nullable void (^)(id<OCTManager> manager))successBlock
|
||||
failureBlock:(nullable void (^)(NSError *error))failureBlock;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@ -0,0 +1,84 @@
|
||||
// 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 "OCTChat.h"
|
||||
#import "OCTFriend.h"
|
||||
#import "OCTManagerConstants.h"
|
||||
|
||||
/**
|
||||
* Please note that all properties of this object are readonly.
|
||||
* All management of calls are handeled through OCTCallSubmanagerCalls.
|
||||
*/
|
||||
|
||||
@interface OCTCall : OCTObject
|
||||
|
||||
/**
|
||||
* OCTChat related session with the call.
|
||||
**/
|
||||
@property (nonnull) OCTChat *chat;
|
||||
|
||||
/**
|
||||
* Call status
|
||||
**/
|
||||
@property OCTCallStatus status;
|
||||
|
||||
/**
|
||||
* This property contains paused status for Active call.
|
||||
*/
|
||||
@property OCTCallPausedStatus pausedStatus;
|
||||
|
||||
/**
|
||||
* The friend who started the call.
|
||||
* Nil if the you started the call yourself.
|
||||
**/
|
||||
@property (nullable) OCTFriend *caller;
|
||||
|
||||
/**
|
||||
* Video device is active for this call
|
||||
*/
|
||||
@property BOOL videoIsEnabled;
|
||||
|
||||
/**
|
||||
* Friend is sending audio.
|
||||
*/
|
||||
@property BOOL friendSendingAudio;
|
||||
|
||||
/**
|
||||
* Friend is sending video.
|
||||
*/
|
||||
@property BOOL friendSendingVideo;
|
||||
|
||||
/**
|
||||
* Friend is accepting audio.
|
||||
*/
|
||||
@property BOOL friendAcceptingAudio;
|
||||
|
||||
/**
|
||||
* Friend is accepting video.
|
||||
*/
|
||||
@property BOOL friendAcceptingVideo;
|
||||
|
||||
/**
|
||||
* Call duration
|
||||
**/
|
||||
@property NSTimeInterval callDuration;
|
||||
|
||||
/**
|
||||
* The on hold start interval when call was put on hold.
|
||||
*/
|
||||
@property NSTimeInterval onHoldStartInterval;
|
||||
|
||||
/**
|
||||
* The date when the call was put on hold.
|
||||
*/
|
||||
- (nullable NSDate *)onHoldDate;
|
||||
|
||||
/**
|
||||
* Indicates if call is outgoing or incoming.
|
||||
* In case if it is incoming you can check `caller` property for friend.
|
||||
**/
|
||||
- (BOOL)isOutgoing;
|
||||
|
||||
@end
|
@ -0,0 +1,74 @@
|
||||
// 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 "OCTObject.h"
|
||||
#import "OCTFriend.h"
|
||||
|
||||
@class OCTMessageAbstract;
|
||||
|
||||
/**
|
||||
* Please note that all properties of this object are readonly.
|
||||
* You can change some of them only with appropriate method in OCTSubmanagerObjects.
|
||||
*/
|
||||
@interface OCTChat : OCTObject
|
||||
|
||||
/**
|
||||
* Array with OCTFriends that participate in this chat.
|
||||
*/
|
||||
@property (nonnull) RLMArray<OCTFriend> *friends;
|
||||
|
||||
/**
|
||||
* The latest message that was send or received.
|
||||
*/
|
||||
@property (nullable) OCTMessageAbstract *lastMessage;
|
||||
|
||||
/**
|
||||
* This property can be used for storing entered text that wasn't send yet.
|
||||
*
|
||||
* To change please use OCTSubmanagerObjects method.
|
||||
*
|
||||
* May be empty.
|
||||
*/
|
||||
@property (nullable) NSString *enteredText;
|
||||
|
||||
/**
|
||||
* This property stores last date interval when chat was read.
|
||||
* `hasUnreadMessages` method use lastReadDateInterval to determine if there are unread messages.
|
||||
*
|
||||
* To change please use OCTSubmanagerObjects method.
|
||||
*/
|
||||
@property NSTimeInterval lastReadDateInterval;
|
||||
|
||||
/**
|
||||
* Date interval of lastMessage or chat creationDate if there is no last message.
|
||||
*
|
||||
* This property is workaround to support sorting. Should be replaced with keypath
|
||||
* lastMessage.dateInterval sorting in future.
|
||||
* See https://github.com/realm/realm-cocoa/issues/1277
|
||||
*/
|
||||
@property NSTimeInterval lastActivityDateInterval;
|
||||
|
||||
/**
|
||||
* The date when chat was read last time.
|
||||
*/
|
||||
- (nullable NSDate *)lastReadDate;
|
||||
|
||||
/**
|
||||
* Returns date of lastMessage or chat creationDate if there is no last message.
|
||||
*/
|
||||
- (nullable NSDate *)lastActivityDate;
|
||||
|
||||
/**
|
||||
* If there are unread messages in chat YES is returned. All messages that have date later than lastReadDateInterval
|
||||
* are considered as unread.
|
||||
*
|
||||
* Please note that you have to set lastReadDateInterval to make this method work.
|
||||
*
|
||||
* @return YES if there are unread messages, NO otherwise.
|
||||
*/
|
||||
- (BOOL)hasUnreadMessages;
|
||||
|
||||
@end
|
||||
|
||||
RLM_ARRAY_TYPE(OCTChat)
|
@ -0,0 +1,110 @@
|
||||
// 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 "OCTObject.h"
|
||||
#import "OCTToxConstants.h"
|
||||
|
||||
/**
|
||||
* Class that represents friend (or just simply contact).
|
||||
*
|
||||
* Please note that all properties of this object are readonly.
|
||||
* You can change some of them only with appropriate method in OCTSubmanagerObjects.
|
||||
*/
|
||||
@interface OCTFriend : OCTObject
|
||||
|
||||
/**
|
||||
* Friend number that is unique for Tox.
|
||||
* In case if friend will be deleted, old id may be reused on new friend creation.
|
||||
*/
|
||||
@property OCTToxFriendNumber friendNumber;
|
||||
|
||||
/**
|
||||
* Nickname of friend.
|
||||
*
|
||||
* When friend is created it is set to the publicKey.
|
||||
* It is set to name when obtaining name for the first time.
|
||||
* After that name is unchanged (unless it is changed explicitly).
|
||||
*
|
||||
* To change please use OCTSubmanagerObjects method.
|
||||
*/
|
||||
@property (nonnull) NSString *nickname;
|
||||
|
||||
/**
|
||||
* Public key of a friend, is kOCTToxPublicKeyLength length.
|
||||
* Is constant, cannot be changed.
|
||||
*/
|
||||
@property (nonnull) NSString *publicKey;
|
||||
|
||||
/**
|
||||
* Name of a friend.
|
||||
*
|
||||
* May be empty.
|
||||
*/
|
||||
@property (nullable) NSString *name;
|
||||
|
||||
/**
|
||||
* Status message of a friend.
|
||||
*
|
||||
* May be empty.
|
||||
*/
|
||||
@property (nullable) NSString *statusMessage;
|
||||
|
||||
/**
|
||||
* Status message of a friend.
|
||||
*/
|
||||
@property OCTToxUserStatus status;
|
||||
|
||||
/**
|
||||
* Property specifies if friend is connected. For type of connection you can check
|
||||
* connectionStatus property.
|
||||
*/
|
||||
@property BOOL isConnected;
|
||||
|
||||
/**
|
||||
* Connection status message of a friend.
|
||||
*/
|
||||
@property OCTToxConnectionStatus connectionStatus;
|
||||
|
||||
/**
|
||||
* The date interval when friend was last seen online.
|
||||
* Contains actual information in case if friend has connectionStatus offline.
|
||||
*/
|
||||
@property NSTimeInterval lastSeenOnlineInterval;
|
||||
|
||||
/**
|
||||
* Whether friend is typing now in current chat.
|
||||
*/
|
||||
@property BOOL isTyping;
|
||||
|
||||
/**
|
||||
* Data representation of friend's avatar.
|
||||
*/
|
||||
@property (nullable) NSData *avatarData;
|
||||
|
||||
/**
|
||||
* The date when friend was last seen online.
|
||||
* Contains actual information in case if friend has connectionStatus offline.
|
||||
*/
|
||||
- (nullable NSDate *)lastSeenOnline;
|
||||
|
||||
/**
|
||||
* Push Token of a friend.
|
||||
*
|
||||
* May be empty.
|
||||
*/
|
||||
@property (nullable) NSString *pushToken;
|
||||
|
||||
/**
|
||||
* Indicate if a friend has msgV3 Capability.
|
||||
*/
|
||||
@property BOOL msgv3Capability;
|
||||
|
||||
/**
|
||||
* Friend's capabilities. A 64 bit unsigned integer.
|
||||
*/
|
||||
@property (nonnull) NSString *capabilities2;
|
||||
|
||||
@end
|
||||
|
||||
RLM_ARRAY_TYPE(OCTFriend)
|
@ -0,0 +1,35 @@
|
||||
// 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 "OCTObject.h"
|
||||
|
||||
/**
|
||||
* Please note that all properties of this object are readonly.
|
||||
* You can change some of them only with appropriate method in OCTSubmanagerObjects.
|
||||
*/
|
||||
@interface OCTFriendRequest : OCTObject
|
||||
|
||||
/**
|
||||
* Public key of a friend.
|
||||
*/
|
||||
@property (nonnull) NSString *publicKey;
|
||||
|
||||
/**
|
||||
* Message that friend did send with friend request.
|
||||
*/
|
||||
@property (nullable) NSString *message;
|
||||
|
||||
/**
|
||||
* Date interval when friend request was received (since 1970).
|
||||
*/
|
||||
@property NSTimeInterval dateInterval;
|
||||
|
||||
/**
|
||||
* Date when friend request was received.
|
||||
*/
|
||||
- (nonnull NSDate *)date;
|
||||
|
||||
@end
|
||||
|
||||
RLM_ARRAY_TYPE(OCTFriendRequest)
|
@ -0,0 +1,67 @@
|
||||
// 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 "OCTObject.h"
|
||||
|
||||
@class OCTFriend;
|
||||
@class OCTChat;
|
||||
@class OCTMessageText;
|
||||
@class OCTMessageFile;
|
||||
@class OCTMessageCall;
|
||||
|
||||
/**
|
||||
* An abstract message that represents one chunk of chat history.
|
||||
*
|
||||
* Please note that all properties of this object are readonly.
|
||||
* You can change some of them only with appropriate method in OCTSubmanagerObjects.
|
||||
*/
|
||||
@interface OCTMessageAbstract : OCTObject
|
||||
|
||||
/**
|
||||
* The date interval when message was send/received.
|
||||
*/
|
||||
@property NSTimeInterval dateInterval;
|
||||
|
||||
/**
|
||||
* Unixtimestamp when messageV3 was sent or 0.
|
||||
*/
|
||||
@property NSTimeInterval tssent;
|
||||
|
||||
/**
|
||||
* Unixtimestamp when messageV3 was received or 0.
|
||||
*/
|
||||
@property NSTimeInterval tsrcvd;
|
||||
|
||||
/**
|
||||
* Unique identifier of friend that have send message.
|
||||
* If the message if outgoing senderUniqueIdentifier is nil.
|
||||
*/
|
||||
@property (nullable) NSString *senderUniqueIdentifier;
|
||||
|
||||
/**
|
||||
* The chat message message belongs to.
|
||||
*/
|
||||
@property (nonnull) NSString *chatUniqueIdentifier;
|
||||
|
||||
/**
|
||||
* Message has one of the following properties.
|
||||
*/
|
||||
@property (nullable) OCTMessageText *messageText;
|
||||
@property (nullable) OCTMessageFile *messageFile;
|
||||
@property (nullable) OCTMessageCall *messageCall;
|
||||
|
||||
/**
|
||||
* The date when message was send/received.
|
||||
*/
|
||||
- (nonnull NSDate *)date;
|
||||
|
||||
/**
|
||||
* Indicates if message is outgoing or incoming.
|
||||
* In case if it is incoming you can check `sender` property for message sender.
|
||||
*/
|
||||
- (BOOL)isOutgoing;
|
||||
|
||||
@end
|
||||
|
||||
RLM_ARRAY_TYPE(OCTMessageAbstract)
|
@ -0,0 +1,20 @@
|
||||
// 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 "OCTObject.h"
|
||||
#import "OCTManagerConstants.h"
|
||||
|
||||
@interface OCTMessageCall : OCTObject
|
||||
|
||||
/**
|
||||
* The length of the call in seconds.
|
||||
**/
|
||||
@property NSTimeInterval callDuration;
|
||||
|
||||
/**
|
||||
* The type of message call.
|
||||
**/
|
||||
@property OCTMessageCallEvent callEvent;
|
||||
|
||||
@end
|
@ -0,0 +1,61 @@
|
||||
// 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 "OCTObject.h"
|
||||
#import "OCTToxConstants.h"
|
||||
#import "OCTManagerConstants.h"
|
||||
|
||||
/**
|
||||
* Message that contains file, that has been send/received. Represents pending, canceled and loaded files.
|
||||
*
|
||||
* Please note that all properties of this object are readonly.
|
||||
* You can change some of them only with appropriate method in OCTSubmanagerObjects.
|
||||
*/
|
||||
@interface OCTMessageFile : OCTObject
|
||||
|
||||
/**
|
||||
* The current state of file.
|
||||
*/
|
||||
@property OCTMessageFileType fileType;
|
||||
|
||||
/**
|
||||
* In case if fileType is equal to OCTMessageFileTypePaused this property will contain information
|
||||
* by whom file transfer was paused.
|
||||
*/
|
||||
@property OCTMessageFilePausedBy pausedBy;
|
||||
|
||||
/**
|
||||
* Size of file in bytes.
|
||||
*/
|
||||
@property OCTToxFileSize fileSize;
|
||||
|
||||
/**
|
||||
* Name of the file as specified by sender. Note that actual fileName in path
|
||||
* may differ from this fileName.
|
||||
*/
|
||||
@property (nullable) NSString *fileName;
|
||||
|
||||
/**
|
||||
* Uniform Type Identifier of file.
|
||||
*/
|
||||
@property (nullable) NSString *fileUTI;
|
||||
|
||||
/**
|
||||
* Path of file on disk. If you need fileName to show to user please use
|
||||
* `fileName` property. filePath has it's own random fileName.
|
||||
*
|
||||
* In case of incoming file filePath will have value only if fileType is OCTMessageFileTypeReady
|
||||
*/
|
||||
- (nullable NSString *)filePath;
|
||||
|
||||
// Properties and methods below are for internal use.
|
||||
// Do not use them or rely on them. They may change in any moment.
|
||||
|
||||
@property int internalFileNumber;
|
||||
@property (nullable) NSString *internalFilePath;
|
||||
- (void)internalSetFilePath:(nullable NSString *)path;
|
||||
|
||||
@end
|
||||
|
||||
RLM_ARRAY_TYPE(OCTMessageFile)
|
@ -0,0 +1,49 @@
|
||||
// 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 "OCTObject.h"
|
||||
#import "OCTToxConstants.h"
|
||||
|
||||
@class OCTToxConstants;
|
||||
|
||||
/**
|
||||
* Simple text message.
|
||||
*
|
||||
* Please note that all properties of this object are readonly.
|
||||
* You can change some of them only with appropriate method in OCTSubmanagerObjects.
|
||||
*/
|
||||
@interface OCTMessageText : OCTObject
|
||||
|
||||
/**
|
||||
* The text of the message.
|
||||
*/
|
||||
@property (nullable) NSString *text;
|
||||
|
||||
/**
|
||||
* Indicate if message is delivered. Actual only for outgoing messages.
|
||||
*/
|
||||
@property BOOL isDelivered;
|
||||
|
||||
/**
|
||||
* Type of the message.
|
||||
*/
|
||||
@property OCTToxMessageType type;
|
||||
|
||||
@property OCTToxMessageId messageId;
|
||||
|
||||
/**
|
||||
* msgV3 Hash as uppercase Hexstring.
|
||||
*
|
||||
* May be empty if message is not v3.
|
||||
*/
|
||||
@property (nullable) NSString *msgv3HashHex;
|
||||
|
||||
/**
|
||||
* Indicate if message has triggered a push notification.
|
||||
*/
|
||||
@property BOOL sentPush;
|
||||
|
||||
@end
|
||||
|
||||
RLM_ARRAY_TYPE(OCTMessageText)
|
@ -0,0 +1,33 @@
|
||||
// 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 <Realm/Realm.h>
|
||||
|
||||
/**
|
||||
* Please note that all properties of this object are readonly.
|
||||
* You can change some of them only with appropriate method in OCTSubmanagerObjects.
|
||||
*/
|
||||
@interface OCTObject : RLMObject
|
||||
|
||||
/**
|
||||
* The unique identifier of object.
|
||||
*/
|
||||
@property NSString *uniqueIdentifier;
|
||||
|
||||
/**
|
||||
* Returns a string that represents the contents of the receiving class.
|
||||
*/
|
||||
- (NSString *)description;
|
||||
|
||||
/**
|
||||
* Returns a Boolean value that indicates whether the receiver and a given object are equal.
|
||||
*/
|
||||
- (BOOL)isEqual:(id)object;
|
||||
|
||||
/**
|
||||
* Returns an integer that can be used as a table address in a hash table structure.
|
||||
*/
|
||||
- (NSUInteger)hash;
|
||||
|
||||
@end
|
@ -0,0 +1,17 @@
|
||||
// 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 "TargetConditionals.h"
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
typedef UIView OCTView;
|
||||
|
||||
#else
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
typedef NSView OCTView;
|
||||
|
||||
#endif
|
@ -0,0 +1,57 @@
|
||||
// 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 "OCTToxConstants.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol OCTSubmanagerBootstrap <NSObject>
|
||||
|
||||
/**
|
||||
* Add node to bootstrap with.
|
||||
*
|
||||
* This will NOT start bootstrapping. To start actual bootstrapping set all desired nodes
|
||||
* and call `bootstrap` method.
|
||||
*
|
||||
* @param ipv4Host IPv4 hostname or an IP address of the node.
|
||||
* @param ipv6Host IPv4 hostname or an IP address of the node.
|
||||
* @param udpPort The port on the host on which the bootstrap Tox instance is listening.
|
||||
* @param tcpPorts NSNumbers with OCTToxPorts on which the TCP relay is listening.
|
||||
* @param publicKey Public key of the node (of kOCTToxPublicKeyLength length).
|
||||
*/
|
||||
- (void)addNodeWithIpv4Host:(nullable NSString *)ipv4Host
|
||||
ipv6Host:(nullable NSString *)ipv6Host
|
||||
udpPort:(OCTToxPort)udpPort
|
||||
tcpPorts:(NSArray<NSNumber *> *)tcpPorts
|
||||
publicKey:(NSString *)publicKey;
|
||||
|
||||
/**
|
||||
* Add nodes from https://nodes.tox.chat/. objcTox is trying to keep this list up to date.
|
||||
* You can check all nodes and update date in nodes.json file.
|
||||
*
|
||||
* This will NOT start bootstrapping. To start actual bootstrapping set all desired nodes
|
||||
* and call `bootstrap` method.
|
||||
*/
|
||||
- (void)addPredefinedNodes;
|
||||
|
||||
/**
|
||||
* You HAVE TO call this method on startup to connect to Tox network.
|
||||
*
|
||||
* Before calling this method add nodes to bootstrap with.
|
||||
*
|
||||
* After calling this method
|
||||
* - if manager wasn't connected before it will start bootstrapping immediately.
|
||||
* - if it was connected before, it will wait 10 to connect to existing nodes
|
||||
* before starting actually bootstrapping.
|
||||
*
|
||||
* When bootstrapping, submanager will bootstrap 4 random nodes from a list every 5 seconds
|
||||
* until is will be connected.
|
||||
*/
|
||||
- (void)bootstrap;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@ -0,0 +1,145 @@
|
||||
// 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 "OCTView.h"
|
||||
#import "OCTChat.h"
|
||||
#import "OCTToxAVConstants.h"
|
||||
#import "OCTSubmanagerCallsDelegate.h"
|
||||
|
||||
@class OCTToxAV;
|
||||
@class OCTCall;
|
||||
|
||||
@protocol OCTSubmanagerCalls <NSObject>
|
||||
|
||||
@property (nullable, weak, nonatomic) id<OCTSubmanagerCallDelegate> delegate;
|
||||
|
||||
/**
|
||||
* Set the property to YES to enable the microphone, otherwise NO.
|
||||
* Default value is YES at the start of every call;
|
||||
**/
|
||||
@property (nonatomic, assign) BOOL enableMicrophone;
|
||||
|
||||
/**
|
||||
* This must be called once after initialization.
|
||||
* @param error Pointer to an error when setting up.
|
||||
* @return YES on success, otherwise NO.
|
||||
*/
|
||||
- (BOOL)setupAndReturnError:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* This class is responsible for telling the end-user what calls we have available.
|
||||
* We can also initialize a call session from here.
|
||||
* @param chat The chat for which we would like to initiate a call.
|
||||
* @param enableAudio YES for Audio, otherwise NO.
|
||||
* @param enableVideo YES for Video, otherwise NO.
|
||||
* @param error Pointer to an error when attempting to answer a call
|
||||
* @return OCTCall session
|
||||
*/
|
||||
- (nullable OCTCall *)callToChat:(nonnull OCTChat *)chat
|
||||
enableAudio:(BOOL)enableAudio
|
||||
enableVideo:(BOOL)enableVideo
|
||||
error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* Enable video calling for an active call.
|
||||
* Use this when you started a call without video in the first place.
|
||||
* @param enable YES to enable video, NO to stop video sending.
|
||||
* @param call Call to enable video for.
|
||||
* @param error Pointer to an error object.
|
||||
* @return YES on success, otherwise NO.
|
||||
*/
|
||||
- (BOOL)enableVideoSending:(BOOL)enable
|
||||
forCall:(nonnull OCTCall *)call
|
||||
error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* Answer a call
|
||||
* @param call The call session we would like to answer
|
||||
* @param enableAudio YES for Audio, otherwise NO.
|
||||
* @param enableVideo YES for Video, otherwise NO.
|
||||
* @param error Pointer to an error when attempting to answer a call
|
||||
* @return YES if we were able to succesfully answer the call, otherwise NO.
|
||||
*/
|
||||
- (BOOL)answerCall:(nonnull OCTCall *)call
|
||||
enableAudio:(BOOL)enableAudio
|
||||
enableVideo:(BOOL)enableVideo
|
||||
error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* Send call control to call.
|
||||
* @param control The control to send to call.
|
||||
* @param call The appopriate call to send to.
|
||||
* @param error Pointer to error object if there's an issue muting the call.
|
||||
* @return YES if succesful, NO otherwise.
|
||||
*/
|
||||
- (BOOL)sendCallControl:(OCTToxAVCallControl)control
|
||||
toCall:(nonnull OCTCall *)call
|
||||
error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* The OCTView that will have the video feed.
|
||||
*/
|
||||
- (nullable OCTView *)videoFeed;
|
||||
|
||||
/**
|
||||
* The preview video of the user.
|
||||
* You must be in a video call for this to show. Otherwise the layer will
|
||||
* just be black.
|
||||
* @param completionBlock Block responsible for using the layer. This
|
||||
* must not be nil.
|
||||
*/
|
||||
- (void)getVideoCallPreview:(void (^__nonnull)( CALayer *__nullable layer))completionBlock;
|
||||
|
||||
/**
|
||||
* Set the Audio bit rate.
|
||||
* @param bitrate The bitrate to change to.
|
||||
* @param call The Call to set the bitrate for.
|
||||
* @param error Pointer to error object if there's an issue setting the bitrate.
|
||||
*/
|
||||
- (BOOL)setAudioBitrate:(int)bitrate forCall:(nonnull OCTCall *)call error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
#if ! TARGET_OS_IPHONE
|
||||
|
||||
/**
|
||||
* Set input source and output targets for A/V.
|
||||
*
|
||||
* On iPhone OS, you must pass one of the OCT[Input|Output]Device... constants
|
||||
* as the deviceUniqueID.
|
||||
* On OS X, you can get valid deviceUniqueID values from:
|
||||
* - AVFoundation: video and audio (inputs only) (AVCaptureDevice uniqueID)
|
||||
* - Core Audio: audio inputs and outputs (kAudioDevicePropertyDeviceUID).
|
||||
* @param deviceUniqueID The device ID to use. May be nil, in which case
|
||||
* a default device will be used
|
||||
*/
|
||||
- (BOOL)setAudioInputDevice:(nullable NSString *)deviceUniqueID
|
||||
error:(NSError *__nullable *__nullable)error;
|
||||
- (BOOL)setAudioOutputDevice:(nullable NSString *)deviceUniqueID
|
||||
error:(NSError *__nullable *__nullable)error;
|
||||
- (BOOL)setVideoInputDevice:(nullable NSString *)deviceUniqueID
|
||||
error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Send the audio to the speaker
|
||||
* @param speaker YES to send audio to speaker, NO to reset to default.
|
||||
* @param error Pointer to error object.
|
||||
* @return YES if successful, otherwise NO.
|
||||
*/
|
||||
- (BOOL)routeAudioToSpeaker:(BOOL)speaker
|
||||
error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* Use a different camera for input.
|
||||
* @param front YES to use the front camera, NO to use the
|
||||
* rear camera. Front camera is used by default.
|
||||
* @error Pointer to error object.
|
||||
* @return YES on success, otherwise NO.
|
||||
*/
|
||||
- (BOOL)switchToCameraFront:(BOOL)front error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
@ -0,0 +1,15 @@
|
||||
// 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/.
|
||||
|
||||
@class OCTCall;
|
||||
@protocol OCTSubmanagerCalls;
|
||||
|
||||
@protocol OCTSubmanagerCallDelegate <NSObject>
|
||||
|
||||
/**
|
||||
* This gets called when we receive a call.
|
||||
**/
|
||||
- (void)callSubmanager:(id<OCTSubmanagerCalls>)callSubmanager receiveCall:(OCTCall *)call audioEnabled:(BOOL)audioEnabled videoEnabled:(BOOL)videoEnabled;
|
||||
|
||||
@end
|
@ -0,0 +1,84 @@
|
||||
// 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 "OCTToxConstants.h"
|
||||
|
||||
@class OCTChat;
|
||||
@class OCTFriend;
|
||||
@class OCTMessageAbstract;
|
||||
|
||||
@protocol OCTSubmanagerChats <NSObject>
|
||||
|
||||
/**
|
||||
* Searches for a chat with specific friend. If chat is not found creates one and returns it.
|
||||
*
|
||||
* @param friend Friend to get/create chat with.
|
||||
*
|
||||
* @return Chat with specific friend.
|
||||
*/
|
||||
- (OCTChat *)getOrCreateChatWithFriend:(OCTFriend *)friend;
|
||||
|
||||
/**
|
||||
* Removes given messages.
|
||||
*
|
||||
* @param messages Array with messages to remove.
|
||||
*
|
||||
* @warning Destructive operation! There is no way to restore messages after removal.
|
||||
*/
|
||||
- (void)removeMessages:(NSArray<OCTMessageAbstract *> *)messages;
|
||||
|
||||
/**
|
||||
* Removes all messages in chat and chat itself.
|
||||
*
|
||||
* @param chat Chat to remove in.
|
||||
* @param removeChat Whether remove chat or not
|
||||
*
|
||||
* @warning Destructive operation! There is no way to restore chat or messages after removal.
|
||||
*/
|
||||
- (void)removeAllMessagesInChat:(OCTChat *)chat removeChat:(BOOL)removeChat;
|
||||
|
||||
/**
|
||||
* Send text message to specific chat
|
||||
*
|
||||
* @param chat Chat send message to.
|
||||
* @param text Text to send.
|
||||
* @param type Type of message to send.
|
||||
* @param successBlock Block called when message was successfully send.
|
||||
* @param message Message that was send.
|
||||
* @param failureBlock Block called when submanager failed to send message.
|
||||
* @param error Error that occurred. See OCTToxErrorFriendSendMessage for all error codes.
|
||||
*/
|
||||
- (void)sendMessageToChat:(OCTChat *)chat
|
||||
text:(NSString *)text
|
||||
type:(OCTToxMessageType)type
|
||||
successBlock:(void (^)(OCTMessageAbstract *message))userSuccessBlock
|
||||
failureBlock:(void (^)(NSError *error))userFailureBlock;
|
||||
|
||||
/**
|
||||
* Trigger PUSH Message to yourself
|
||||
*/
|
||||
- (void)sendOwnPush;
|
||||
|
||||
/**
|
||||
* Trigger PUSH Message to Friend if the Text Message was sent in a period where the friend
|
||||
* was online to us, but the friend was in fact already offline.
|
||||
* so no message was sent AND not PUSH was triggered.
|
||||
*/
|
||||
- (void)sendMessagePushToChat:(OCTChat *)chat;
|
||||
|
||||
/**
|
||||
* Set our typing status for a chat. You are responsible for turning it on or off.
|
||||
*
|
||||
* @param isTyping Status showing whether user is typing or not.
|
||||
* @param chat Chat to set typing status.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorSetTyping for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)setIsTyping:(BOOL)isTyping inChat:(OCTChat *)chat error:(NSError **)error;
|
||||
|
||||
@end
|
@ -0,0 +1,124 @@
|
||||
// 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>
|
||||
|
||||
@class OCTMessageAbstract;
|
||||
@class OCTChat;
|
||||
@protocol OCTSubmanagerFilesProgressSubscriber;
|
||||
|
||||
@protocol OCTSubmanagerFiles <NSObject>
|
||||
|
||||
/**
|
||||
* Send given data to particular chat. After sending OCTMessageAbstract with messageFile will be added to this chat.
|
||||
* You can monitor progress using this message.
|
||||
*
|
||||
* File will be saved in uploaded files directory (see OCTFileStorageProtocol).
|
||||
*
|
||||
* @param data Data to send.
|
||||
* @param fileName Name of the file.
|
||||
* @param chat Chat to send data to.
|
||||
* @param failureBlock Block that will be called in case of upload failure.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTSendFileError for all error codes.
|
||||
*/
|
||||
- (void)sendData:(nonnull NSData *)data
|
||||
withFileName:(nonnull NSString *)fileName
|
||||
toChat:(nonnull OCTChat *)chat
|
||||
failureBlock:(nullable void (^)(NSError *__nonnull error))failureBlock;
|
||||
|
||||
/**
|
||||
* Send given file to particular chat. After sending OCTMessageAbstract with messageFile will be added to this chat.
|
||||
* You can monitor progress using this message.
|
||||
*
|
||||
* @param filePath Path of file to upload.
|
||||
* @param moveToUploads If YES file will be moved to uploads directory.
|
||||
* @param chat Chat to send file to.
|
||||
* @param failureBlock Block that will be called in case of upload failure.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTSendFileError for all error codes.
|
||||
*/
|
||||
- (void)sendFileAtPath:(nonnull NSString *)filePath
|
||||
moveToUploads:(BOOL)moveToUploads
|
||||
toChat:(nonnull OCTChat *)chat
|
||||
failureBlock:(nullable void (^)(NSError *__nonnull error))failureBlock;
|
||||
|
||||
/**
|
||||
* Accept file transfer.
|
||||
*
|
||||
* @param message Message with file transfer. Message should be incoming and have OCTMessageFile with
|
||||
* fileType OCTMessageFileTypeWaitingConfirmation. Otherwise nothing will happen.
|
||||
* @param failureBlock Block that will be called in case of download failure.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTAcceptFileError for all error codes.
|
||||
*/
|
||||
- (void)acceptFileTransfer:(nonnull OCTMessageAbstract *)message
|
||||
failureBlock:(nullable void (^)(NSError *__nonnull error))failureBlock;
|
||||
|
||||
/**
|
||||
* Cancel file transfer. File transfer can be waiting confirmation or active.
|
||||
*
|
||||
* @param message Message with file transfer. Message should have OCTMessageFile. Otherwise nothing will happen.
|
||||
*/
|
||||
- (BOOL)cancelFileTransfer:(nonnull OCTMessageAbstract *)message error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* Retry to send file using same OCTMessageAbstract. This message should have Canceled type, otherwise retry will failure.
|
||||
*
|
||||
* @param message File transfer message to send.
|
||||
* @param failureBlock Block that will be called in case of upload failure.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTSendFileError for all error codes.
|
||||
*/
|
||||
- (void)retrySendingFile:(nonnull OCTMessageAbstract *)message
|
||||
failureBlock:(nullable void (^)(NSError *__nonnull error))failureBlock;
|
||||
|
||||
/**
|
||||
* Pause or resume file transfer.
|
||||
* - For pausing transfer should be in Loading state or paused by friend, otherwise nothing will happen.
|
||||
* - For resuming transfer should be in Paused state and paused by user, otherwise nothing will happen.
|
||||
*
|
||||
* @param pause Flag notifying of pausing/resuming file transfer.
|
||||
* @param message Message with file transfer. Message should have OCTMessageFile.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTFileTransferError for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)pauseFileTransfer:(BOOL)pause
|
||||
message:(nonnull OCTMessageAbstract *)message
|
||||
error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* Add progress subscriber for given file transfer. Subscriber will receive progress immediately after subscribing.
|
||||
* File transfer should be in Loading or Paused state, otherwise subscriber won't be added.
|
||||
*
|
||||
* @param subscriber Object listening to progress protocol.
|
||||
* @param message Message with file transfer. Message should have OCTMessageFile. Otherwise nothing will happen.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTFileTransferError for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*
|
||||
* @warning Subscriber will be stored as weak reference, so it is safe to dealloc it without unsubscribing.
|
||||
*/
|
||||
- (BOOL)addProgressSubscriber:(nonnull id<OCTSubmanagerFilesProgressSubscriber>)subscriber
|
||||
forFileTransfer:(nonnull OCTMessageAbstract *)message
|
||||
error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* Remove progress subscriber for given file transfer.
|
||||
*
|
||||
* @param subscriber Object listening to progress protocol.
|
||||
* @param message Message with file transfer. Message should have OCTMessageFile. Otherwise nothing will happen.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTFileTransferError for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)removeProgressSubscriber:(nonnull id<OCTSubmanagerFilesProgressSubscriber>)subscriber
|
||||
forFileTransfer:(nonnull OCTMessageAbstract *)message
|
||||
error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
@end
|
@ -0,0 +1,30 @@
|
||||
// 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>
|
||||
|
||||
@class OCTMessageAbstract;
|
||||
|
||||
@protocol OCTSubmanagerFilesProgressSubscriber <NSObject>
|
||||
|
||||
/**
|
||||
* Method called on download/upload progress.
|
||||
*
|
||||
* @param progress Progress of download/upload. From 0.0 to 1.0.
|
||||
* @param message File message with progress update.
|
||||
*/
|
||||
- (void)submanagerFilesOnProgressUpdate:(float)progress message:(nonnull OCTMessageAbstract *)message;
|
||||
|
||||
/**
|
||||
* Method called on download/upload eta update.
|
||||
*
|
||||
* @param eta Estimated time of finish of download/upload.
|
||||
* @param bytesPerSecond Speed of download/upload.
|
||||
* @param message File message with progress update.
|
||||
*/
|
||||
- (void)submanagerFilesOnEtaUpdate:(CFTimeInterval)eta
|
||||
bytesPerSecond:(OCTToxFileSize)bytesPerSecond
|
||||
message:(nonnull OCTMessageAbstract *)message;
|
||||
|
||||
@end
|
@ -0,0 +1,53 @@
|
||||
// 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>
|
||||
|
||||
@class OCTFriendRequest;
|
||||
@class OCTFriend;
|
||||
|
||||
@protocol OCTSubmanagerFriends <NSObject>
|
||||
|
||||
/**
|
||||
* Send friend request to given address. Automatically adds friend with this address to friend list.
|
||||
*
|
||||
* @param address Address of a friend. If required.
|
||||
* @param message Message to send with friend request. Is required.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFriendAdd for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)sendFriendRequestToAddress:(NSString *)address message:(NSString *)message error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Approve given friend request. After approving new friend will be added and friendRequest will be removed.
|
||||
*
|
||||
* @param friendRequest Friend request to approve.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFriendAdd for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)approveFriendRequest:(OCTFriendRequest *)friendRequest error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Remove friend request from list. This cannot be undone.
|
||||
*
|
||||
* @param friendRequest Friend request to remove.
|
||||
*/
|
||||
- (void)removeFriendRequest:(OCTFriendRequest *)friendRequest;
|
||||
|
||||
/**
|
||||
* Remove friend from list. This cannot be undone.
|
||||
*
|
||||
* @param friend Friend to remove.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFriendDelete for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)removeFriend:(OCTFriend *)friend error:(NSError **)error;
|
||||
|
||||
@end
|
@ -0,0 +1,72 @@
|
||||
// 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 "OCTManagerConstants.h"
|
||||
|
||||
@class OCTObject;
|
||||
@class OCTFriend;
|
||||
@class OCTChat;
|
||||
@class RLMResults;
|
||||
|
||||
@protocol OCTSubmanagerObjects <NSObject>
|
||||
|
||||
/**
|
||||
* This property can be used to save any generic data you like.
|
||||
*
|
||||
* The default value is nil.
|
||||
*/
|
||||
@property (strong, nonatomic) NSData *genericSettingsData;
|
||||
|
||||
/**
|
||||
* Returns fetch request for specified type.
|
||||
*
|
||||
* @param type Type of fetch request.
|
||||
* @param predicate Predicate that represents search query.
|
||||
*
|
||||
* @return RLMResults with objects of specified type.
|
||||
*/
|
||||
- (RLMResults *)objectsForType:(OCTFetchRequestType)type predicate:(NSPredicate *)predicate;
|
||||
|
||||
/**
|
||||
* Returns object for specified type with uniqueIdentifier.
|
||||
*
|
||||
* @param uniqueIdentifier Unique identifier of object.
|
||||
* @param type Type of object.
|
||||
*
|
||||
* @return Object of specified type or nil, if object does not exist.
|
||||
*/
|
||||
- (OCTObject *)objectWithUniqueIdentifier:(NSString *)uniqueIdentifier forType:(OCTFetchRequestType)type;
|
||||
|
||||
#pragma mark - Friends
|
||||
|
||||
/**
|
||||
* Sets nickname property for friend.
|
||||
*
|
||||
* @param friend Friend to change.
|
||||
* @param nickname New nickname. If nickname is empty or nil, it will be set to friends name.
|
||||
* If friend don't have name, it will be set to friends publicKey.
|
||||
*/
|
||||
- (void)changeFriend:(OCTFriend *)friend nickname:(NSString *)nickname;
|
||||
|
||||
#pragma mark - Chats
|
||||
|
||||
/**
|
||||
* Sets enteredText property for chat.
|
||||
*
|
||||
* @param chat Chat to change.
|
||||
* @param enteredText New text.
|
||||
*/
|
||||
- (void)changeChat:(OCTChat *)chat enteredText:(NSString *)enteredText;
|
||||
|
||||
/**
|
||||
* Sets lastReadDateInterval property for chat.
|
||||
*
|
||||
* @param chat Chat to change.
|
||||
* @param lastReadDateInterval New interval.
|
||||
*/
|
||||
- (void)changeChat:(OCTChat *)chat lastReadDateInterval:(NSTimeInterval)lastReadDateInterval;
|
||||
|
||||
@end
|
@ -0,0 +1,104 @@
|
||||
// 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 "OCTToxConstants.h"
|
||||
|
||||
@protocol OCTSubmanagerUser;
|
||||
@protocol OCTSubmanagerUserDelegate <NSObject>
|
||||
- (void)submanagerUser:(nonnull id<OCTSubmanagerUser>)submanager connectionStatusUpdate:(OCTToxConnectionStatus)connectionStatus;
|
||||
@end
|
||||
|
||||
@protocol OCTSubmanagerUser <NSObject>
|
||||
|
||||
@property (weak, nonatomic, nullable) id<OCTSubmanagerUserDelegate> delegate;
|
||||
|
||||
/**
|
||||
* Indicates if client is connected to the DHT.
|
||||
*/
|
||||
@property (assign, nonatomic, readonly) OCTToxConnectionStatus connectionStatus;
|
||||
|
||||
/**
|
||||
* Client's address.
|
||||
*
|
||||
* Address for Tox as a hex string. Address is kOCTToxAddressLength length and has following format:
|
||||
* [publicKey (32 bytes, 64 characters)][nospam number (4 bytes, 8 characters)][checksum (2 bytes, 4 characters)]
|
||||
*/
|
||||
@property (strong, nonatomic, readonly, nonnull) NSString *userAddress;
|
||||
|
||||
/**
|
||||
* Client's Tox Public Key (long term public key) of kOCTToxPublicKeyLength.
|
||||
*/
|
||||
@property (strong, nonatomic, readonly, nonnull) NSString *publicKey;
|
||||
|
||||
/**
|
||||
* Client's nospam part of the address. Any 32 bit unsigned integer.
|
||||
*/
|
||||
@property (assign, nonatomic) OCTToxNoSpam nospam;
|
||||
|
||||
/**
|
||||
* Client's capabilities. A 64 bit unsigned integer.
|
||||
*/
|
||||
@property (nonatomic, readonly) OCTToxCapabilities capabilities;
|
||||
|
||||
/**
|
||||
* Client's user status.
|
||||
*/
|
||||
@property (assign, nonatomic) OCTToxUserStatus userStatus;
|
||||
|
||||
/**
|
||||
* Set the nickname for the client.
|
||||
*
|
||||
* @param name Name to be set. Minimum length of name is 1 byte.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorSetInfoCode for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)setUserName:(nullable NSString *)name error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* Get client's nickname.
|
||||
*
|
||||
* @return Client's nickname or nil in case of error.
|
||||
*/
|
||||
- (nullable NSString *)userName;
|
||||
|
||||
/**
|
||||
* Set client's status message.
|
||||
*
|
||||
* @param statusMessage Status message to be set.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorSetInfoCode for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)setUserStatusMessage:(nullable NSString *)statusMessage error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* Get client's status message.
|
||||
*
|
||||
* @return Client's status message.
|
||||
*/
|
||||
- (nullable NSString *)userStatusMessage;
|
||||
|
||||
/**
|
||||
* Set user avatar. Avatar should be <= kOCTManagerMaxAvatarSize.
|
||||
*
|
||||
* @param avatar NSData representation of avatar image.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTSetUserAvatarError for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)setUserAvatar:(nullable NSData *)avatar error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* Get data representation of user avatar.
|
||||
*
|
||||
* @return Data with user avatar if exists.
|
||||
*/
|
||||
- (nullable NSData *)userAvatar;
|
||||
|
||||
@end
|
776
local_pod_repo/objcTox/Classes/Public/Manager/nodes.json
Normal file
776
local_pod_repo/objcTox/Classes/Public/Manager/nodes.json
Normal file
@ -0,0 +1,776 @@
|
||||
{
|
||||
"last_scan": 1675968658,
|
||||
"last_refresh": 1675968601,
|
||||
"nodes": [
|
||||
{
|
||||
"ipv4": "144.217.167.73",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
3389,
|
||||
33445
|
||||
],
|
||||
"public_key": "7E5668E0EE09E19F320AD47902419331FFEE147BB3606769CFBE921A2A2FD34C",
|
||||
"maintainer": "velusip",
|
||||
"location": "CA",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002013",
|
||||
"motd": "Jera",
|
||||
"last_ping": 1675968658
|
||||
},
|
||||
{
|
||||
"ipv4": "tox.abilinski.com",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
33445
|
||||
],
|
||||
"public_key": "10C00EB250C3233E343E2AEBA07115A5C28920E9C8D29492F6D00B29049EDC7E",
|
||||
"maintainer": "AnthonyBilinski",
|
||||
"location": "CA",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002013",
|
||||
"motd": "Running https://github.com/toktok/c-toxcore v0.2.13. qTox best Tox! Contact: AC18841E56CCDEE16E93E10E6AB2765BE54277D67F1372921B5B418A6B330D3D3FAFA60B0931",
|
||||
"last_ping": 1675968658
|
||||
},
|
||||
{
|
||||
"ipv4": "198.199.98.108",
|
||||
"ipv6": "2604:a880:1:20::32f:1001",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
33445,
|
||||
3389
|
||||
],
|
||||
"public_key": "BEF0CFB37AF874BD17B9A8F9FE64C75521DB95A37D33C5BDB00E9CF58659C04F",
|
||||
"maintainer": "Cody",
|
||||
"location": "US",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002015",
|
||||
"motd": "Cody's Tox node!",
|
||||
"last_ping": 1675968658
|
||||
},
|
||||
{
|
||||
"ipv4": "tox.kurnevsky.net",
|
||||
"ipv6": "tox.kurnevsky.net",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "82EF82BA33445A1F91A7DB27189ECFC0C013E06E3DA71F588ED692BED625EC23",
|
||||
"maintainer": "kurnevsky",
|
||||
"location": "NL",
|
||||
"status_udp": true,
|
||||
"status_tcp": false,
|
||||
"version": "3000002000",
|
||||
"motd": "Hi from tox-rs!",
|
||||
"last_ping": 1675968658
|
||||
},
|
||||
{
|
||||
"ipv4": "205.185.115.131",
|
||||
"ipv6": "-",
|
||||
"port": 53,
|
||||
"tcp_ports": [
|
||||
53,
|
||||
443,
|
||||
33445,
|
||||
3389
|
||||
],
|
||||
"public_key": "3091C6BEB2A993F1C6300C16549FABA67098FF3D62C6D253828B531470B53D68",
|
||||
"maintainer": "GDR!",
|
||||
"location": "US",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002018",
|
||||
"motd": "https://gdr.name/tuntox/",
|
||||
"last_ping": 1675968658
|
||||
},
|
||||
{
|
||||
"ipv4": "tox2.abilinski.com",
|
||||
"ipv6": "tox2.abilinski.com",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
33445
|
||||
],
|
||||
"public_key": "7A6098B590BDC73F9723FC59F82B3F9085A64D1B213AAF8E610FD351930D052D",
|
||||
"maintainer": "AnthonyBilinski",
|
||||
"location": "US",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002013",
|
||||
"motd": "Running https://github.com/toktok/c-toxcore v0.2.13. qTox best Tox! Contact: AC18841E56CCDEE16E93E10E6AB2765BE54277D67F1372921B5B418A6B330D3D3FAFA60B0931",
|
||||
"last_ping": 1675968658
|
||||
},
|
||||
{
|
||||
"ipv4": "46.101.197.175",
|
||||
"ipv6": "2a03:b0c0:3:d0::ac:5001",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
3389,
|
||||
33445
|
||||
],
|
||||
"public_key": "CD133B521159541FB1D326DE9850F5E56A6C724B5B8E5EB5CD8D950408E95707",
|
||||
"maintainer": "kotelnik",
|
||||
"location": "DE",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002018",
|
||||
"motd": "Power to Ukraine!",
|
||||
"last_ping": 1675968659
|
||||
},
|
||||
{
|
||||
"ipv4": "tox1.mf-net.eu",
|
||||
"ipv6": "tox1.mf-net.eu",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
3389,
|
||||
33445
|
||||
],
|
||||
"public_key": "B3E5FA80DC8EBD1149AD2AB35ED8B85BD546DEDE261CA593234C619249419506",
|
||||
"maintainer": "2mf",
|
||||
"location": "DE",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002018",
|
||||
"motd": "tox-bootstrapd",
|
||||
"last_ping": 1675968660
|
||||
},
|
||||
{
|
||||
"ipv4": "tox2.mf-net.eu",
|
||||
"ipv6": "tox2.mf-net.eu",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
33445,
|
||||
3389
|
||||
],
|
||||
"public_key": "70EA214FDE161E7432530605213F18F7427DC773E276B3E317A07531F548545F",
|
||||
"maintainer": "2mf",
|
||||
"location": "DE",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002018",
|
||||
"motd": "tox-bootstrapd",
|
||||
"last_ping": 1675968659
|
||||
},
|
||||
{
|
||||
"ipv4": "195.201.7.101",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
3389,
|
||||
33445
|
||||
],
|
||||
"public_key": "B84E865125B4EC4C368CD047C72BCE447644A2DC31EF75BD2CDA345BFD310107",
|
||||
"maintainer": "tux1973",
|
||||
"location": "DE",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002012",
|
||||
"motd": "tox-bootstrapd",
|
||||
"last_ping": 1675968660
|
||||
},
|
||||
{
|
||||
"ipv4": "tox4.plastiras.org",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
443,
|
||||
3389,
|
||||
33445
|
||||
],
|
||||
"public_key": "836D1DA2BE12FE0E669334E437BE3FB02806F1528C2B2782113E0910C7711409",
|
||||
"maintainer": "Tha_14",
|
||||
"location": "MD",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002018",
|
||||
"motd": "Add me on Tox: F0AA7C8C55552E8593B2B77AC6FCA598A40D1F5F52A26C2322690A4BF1DFCB0DD8AEDD2822FF",
|
||||
"last_ping": 1675968659
|
||||
},
|
||||
{
|
||||
"ipv4": "188.225.9.167",
|
||||
"ipv6": "209:dead:ded:4991:49f3:b6c0:9869:3019",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
33445,
|
||||
3389
|
||||
],
|
||||
"public_key": "1911341A83E02503AB1FD6561BD64AF3A9D6C3F12B5FBB656976B2E678644A67",
|
||||
"maintainer": "Nikat",
|
||||
"location": "RU",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002013",
|
||||
"motd": "First yggdrasil tox bootstrapd!!!\nYou can read about it here: https://yggdrasil-network.github.io/",
|
||||
"last_ping": 1675968659
|
||||
},
|
||||
{
|
||||
"ipv4": "122.116.39.151",
|
||||
"ipv6": "2001:b011:8:2f22:1957:7f9d:e31f:96dd",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
3389,
|
||||
33445
|
||||
],
|
||||
"public_key": "5716530A10D362867C8E87EE1CD5362A233BAFBBA4CF47FA73B7CAD368BD5E6E",
|
||||
"maintainer": "miaoski",
|
||||
"location": "TW",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002018",
|
||||
"motd": "tox-bootstrapd",
|
||||
"last_ping": 1675968659
|
||||
},
|
||||
{
|
||||
"ipv4": "tox3.plastiras.org",
|
||||
"ipv6": "tox3.plastiras.org",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
33445,
|
||||
3389
|
||||
],
|
||||
"public_key": "4B031C96673B6FF123269FF18F2847E1909A8A04642BBECD0189AC8AEEADAF64",
|
||||
"maintainer": "Tha_14",
|
||||
"location": "DE",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002018",
|
||||
"motd": "Add me on Tox: F0AA7C8C55552E8593B2B77AC6FCA598A40D1F5F52A26C2322690A4BF1DFCB0DD8AEDD2822FF",
|
||||
"last_ping": 1675968659
|
||||
},
|
||||
{
|
||||
"ipv4": "104.225.141.59",
|
||||
"ipv6": "-",
|
||||
"port": 43334,
|
||||
"tcp_ports": [],
|
||||
"public_key": "933BA20B2E258B4C0D475B6DECE90C7E827FE83EFA9655414E7841251B19A72C",
|
||||
"maintainer": "Gabe",
|
||||
"location": "US",
|
||||
"status_udp": true,
|
||||
"status_tcp": false,
|
||||
"version": "1000002018",
|
||||
"motd": "True peace is in Jesus Matt 11:28-30 Tox ID: 07D7B9018C5C724A2E9EB34C60782F78B7BDF64D5316946EF49F8E6A20F26B4631FEC281D6A4",
|
||||
"last_ping": 1675968658
|
||||
},
|
||||
{
|
||||
"ipv4": "139.162.110.188",
|
||||
"ipv6": "2400:8902::f03c:93ff:fe69:bf77",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
443,
|
||||
3389,
|
||||
33445
|
||||
],
|
||||
"public_key": "F76A11284547163889DDC89A7738CF271797BF5E5E220643E97AD3C7E7903D55",
|
||||
"maintainer": "ToxTom",
|
||||
"location": "CA",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002013",
|
||||
"motd": "ToxTom",
|
||||
"last_ping": 1675968659
|
||||
},
|
||||
{
|
||||
"ipv4": "198.98.49.206",
|
||||
"ipv6": "2605:6400:10:caa:1:be:a:7001",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
33445
|
||||
],
|
||||
"public_key": "28DB44A3CEEE69146469855DFFE5F54DA567F5D65E03EFB1D38BBAEFF2553255",
|
||||
"maintainer": "Cüber",
|
||||
"location": "US",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002013",
|
||||
"motd": "Tox",
|
||||
"last_ping": 1675968660
|
||||
},
|
||||
{
|
||||
"ipv4": "172.105.109.31",
|
||||
"ipv6": "2600:3c04::f03c:92ff:fe30:5df",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
33445
|
||||
],
|
||||
"public_key": "D46E97CF995DC1820B92B7D899E152A217D36ABE22730FEA4B6BF1BFC06C617C",
|
||||
"maintainer": "amr",
|
||||
"location": "CA",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002018",
|
||||
"motd": "FrozenDev Node: tox-bootstrapd Add me on tox: A625D9E9EAAA7B40C399F50BA8B255836EE5A09B6DD0C54CF0E190E24544DC39237D6389FAED",
|
||||
"last_ping": 1675968660
|
||||
},
|
||||
{
|
||||
"ipv4": "91.146.66.26",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "B5E7DAC610DBDE55F359C7F8690B294C8E4FCEC4385DE9525DBFA5523EAD9D53",
|
||||
"maintainer": "Toxdaemon",
|
||||
"location": "EE",
|
||||
"status_udp": true,
|
||||
"status_tcp": false,
|
||||
"version": "1000002013",
|
||||
"motd": "tox-bootstrapd 91.146.66.26",
|
||||
"last_ping": 1675968658
|
||||
},
|
||||
{
|
||||
"ipv4": "tox01.ky0uraku.xyz",
|
||||
"ipv6": "tox01.ky0uraku.xyz",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
33445
|
||||
],
|
||||
"public_key": "FD04EB03ABC5FC5266A93D37B4D6D6171C9931176DC68736629552D8EF0DE174",
|
||||
"maintainer": "ky0uraku",
|
||||
"location": "NL",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002013",
|
||||
"motd": "ky0uraku tox01 node",
|
||||
"last_ping": 1675968660
|
||||
},
|
||||
{
|
||||
"ipv4": "tox02.ky0uraku.xyz",
|
||||
"ipv6": "tox02.ky0uraku.xyz",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
33445
|
||||
],
|
||||
"public_key": "D3D6D7C0C7009FC75406B0A49E475996C8C4F8BCE1E6FC5967DE427F8F600527",
|
||||
"maintainer": "ky0uraku",
|
||||
"location": "FR",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002016",
|
||||
"motd": "ky0uraku tox02 node",
|
||||
"last_ping": 1675968660
|
||||
},
|
||||
{
|
||||
"ipv4": "tox.plastiras.org",
|
||||
"ipv6": "tox.plastiras.org",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
33445,
|
||||
443
|
||||
],
|
||||
"public_key": "8E8B63299B3D520FB377FE5100E65E3322F7AE5B20A0ACED2981769FC5B43725",
|
||||
"maintainer": "Tha_14",
|
||||
"location": "LU",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002018",
|
||||
"motd": "Add me on Tox: F0AA7C8C55552E8593B2B77AC6FCA598A40D1F5F52A26C2322690A4BF1DFCB0DD8AEDD2822FF",
|
||||
"last_ping": 1675968659
|
||||
},
|
||||
{
|
||||
"ipv4": "kusoneko.moe",
|
||||
"ipv6": "kusoneko.moe",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
33445
|
||||
],
|
||||
"public_key": "BE7ED53CD924813507BA711FD40386062E6DC6F790EFA122C78F7CDEEE4B6D1B",
|
||||
"maintainer": "Kusoneko",
|
||||
"location": "CA",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002013",
|
||||
"motd": "Managed by kusoneko (ID:D8E4A5E926A4E7A85FA40F8CA55D47554F043D3C5CDB457187726F19CE20E52C0D7C3FCE9466)",
|
||||
"last_ping": 1675968658
|
||||
},
|
||||
{
|
||||
"ipv4": "tox2.plastiras.org",
|
||||
"ipv6": "tox2.plastiras.org",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
33445,
|
||||
3389
|
||||
],
|
||||
"public_key": "B6626D386BE7E3ACA107B46F48A5C4D522D29281750D44A0CBA6A2721E79C951",
|
||||
"maintainer": "Tha_14",
|
||||
"location": "DE",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002018",
|
||||
"motd": "Add me on Tox: F0AA7C8C55552E8593B2B77AC6FCA598A40D1F5F52A26C2322690A4BF1DFCB0DD8AEDD2822FF",
|
||||
"last_ping": 1675968659
|
||||
},
|
||||
{
|
||||
"ipv4": "172.104.215.182",
|
||||
"ipv6": "2600:3c03::f03c:93ff:fe7f:6096",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
443,
|
||||
33445,
|
||||
3389
|
||||
],
|
||||
"public_key": "DA2BD927E01CD05EBCC2574EBE5BEBB10FF59AE0B2105A7D1E2B40E49BB20239",
|
||||
"maintainer": "zero-one",
|
||||
"location": "US",
|
||||
"status_udp": true,
|
||||
"status_tcp": true,
|
||||
"version": "1000002018",
|
||||
"motd": "tox-bootstrapd",
|
||||
"last_ping": 1675968658
|
||||
},
|
||||
{
|
||||
"ipv4": "5.19.249.240",
|
||||
"ipv6": "-",
|
||||
"port": 38296,
|
||||
"tcp_ports": [
|
||||
38296,
|
||||
3389
|
||||
],
|
||||
"public_key": "DA98A4C0CD7473A133E115FEA2EBDAEEA2EF4F79FD69325FC070DA4DE4BA3238",
|
||||
"maintainer": "Toxdaemon",
|
||||
"location": "RU",
|
||||
"status_udp": false,
|
||||
"status_tcp": true,
|
||||
"version": "",
|
||||
"motd": "",
|
||||
"last_ping": 1675968659
|
||||
},
|
||||
{
|
||||
"ipv4": "NONE",
|
||||
"ipv6": "2607:f130:0:f8::4c85:a645",
|
||||
"port": 33445,
|
||||
"tcp_ports": [
|
||||
3389,
|
||||
33445
|
||||
],
|
||||
"public_key": "8AFE1FC6426E5B77AB80318ED64F5F76341695B9FB47AB8AC9537BF5EE9E9D29",
|
||||
"maintainer": "Busindre",
|
||||
"location": "US",
|
||||
"status_udp": false,
|
||||
"status_tcp": true,
|
||||
"version": "",
|
||||
"motd": "",
|
||||
"last_ping": 1675968658
|
||||
},
|
||||
{
|
||||
"ipv4": "91.219.59.156",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "8E7D0B859922EF569298B4D261A8CCB5FEA14FB91ED412A7603A585A25698832",
|
||||
"maintainer": "ray65536",
|
||||
"location": "RU",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "1000002013",
|
||||
"motd": "Ray's Tox Node. TOX ID:3C3D6DB24D24754393679E59F198EF45EE26835AEF7EA3E3ECEA40E204F2B828BE86DF012ABF",
|
||||
"last_ping": 1669411200
|
||||
},
|
||||
{
|
||||
"ipv4": "85.143.221.42",
|
||||
"ipv6": "2a04:ac00:1:9f00:5054:ff:fe01:becd",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "DA4E4ED4B697F2E9B000EEFE3A34B554ACD3F45F5C96EAEA2516DD7FF9AF7B43",
|
||||
"maintainer": "MAH69K",
|
||||
"location": "RU",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "1000002013",
|
||||
"motd": "Saluton! Mia Tox ID: B229B7BD68FC66C2716EAB8671A461906321C764782D7B3EDBB650A315F6C458EF744CE89F07. Scribu! ;)",
|
||||
"last_ping": 1667642040
|
||||
},
|
||||
{
|
||||
"ipv4": "tox.verdict.gg",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "1C5293AEF2114717547B39DA8EA6F1E331E5E358B35F9B6B5F19317911C5F976",
|
||||
"maintainer": "Deliran",
|
||||
"location": "DE",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "",
|
||||
"motd": "",
|
||||
"last_ping": 0
|
||||
},
|
||||
{
|
||||
"ipv4": "78.46.73.141",
|
||||
"ipv6": "2a01:4f8:120:4091::3",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "02807CF4F8BB8FB390CC3794BDF1E8449E9A8392C5D3F2200019DA9F1E812E46",
|
||||
"maintainer": "Sorunome",
|
||||
"location": "DE",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "",
|
||||
"motd": "",
|
||||
"last_ping": 0
|
||||
},
|
||||
{
|
||||
"ipv4": "tox.initramfs.io",
|
||||
"ipv6": "tox.initramfs.io",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "3F0A45A268367C1BEA652F258C85F4A66DA76BCAA667A49E770BCC4917AB6A25",
|
||||
"maintainer": "initramfs",
|
||||
"location": "TW",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "1000002018",
|
||||
"motd": "initramfs' tox bootstrap node",
|
||||
"last_ping": 1674742139
|
||||
},
|
||||
{
|
||||
"ipv4": "46.229.50.168",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "813C8F4187833EF0655B10F7752141A352248462A567529A38B6BBF73E979307",
|
||||
"maintainer": "Stranger",
|
||||
"location": "UA",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "",
|
||||
"motd": "",
|
||||
"last_ping": 0
|
||||
},
|
||||
{
|
||||
"ipv4": "mk.tox.dcntrlzd.network",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "5E815C25A4E58910A7350EC64ECB32BC9E1919F86844DC97125735C2C30FBE6E",
|
||||
"maintainer": "cryptogospod",
|
||||
"location": "MK",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "",
|
||||
"motd": "",
|
||||
"last_ping": 0
|
||||
},
|
||||
{
|
||||
"ipv4": "tox.novg.net",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "D527E5847F8330D628DAB1814F0A422F6DC9D0A300E6C357634EE2DA88C35463",
|
||||
"maintainer": "blind_oracle",
|
||||
"location": "NL",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "1000002012",
|
||||
"motd": "tox-bootstrapd",
|
||||
"last_ping": 1673387100
|
||||
},
|
||||
{
|
||||
"ipv4": "87.118.126.207",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "0D303B1778CA102035DA01334E7B1855A45C3EFBC9A83B9D916FFDEBC6DD3B2E",
|
||||
"maintainer": "quux",
|
||||
"location": "DE",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "",
|
||||
"motd": "",
|
||||
"last_ping": 0
|
||||
},
|
||||
{
|
||||
"ipv4": "81.169.136.229",
|
||||
"ipv6": "2a01:238:4254:2a00:7aca:fe8c:68e0:27ec",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "E0DB78116AC6500398DDBA2AEEF3220BB116384CAB714C5D1FCD61EA2B69D75E",
|
||||
"maintainer": "9ofSpades",
|
||||
"location": "DE",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "1000002009",
|
||||
"motd": "🂩 wishes happy toxing. 📡",
|
||||
"last_ping": 1674603960
|
||||
},
|
||||
{
|
||||
"ipv4": "floki.blog",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "6C6AF2236F478F8305969CCFC7A7B67C6383558FF87716D38D55906E08E72667",
|
||||
"maintainer": "Floki",
|
||||
"location": "GB",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "",
|
||||
"motd": "",
|
||||
"last_ping": 0
|
||||
},
|
||||
{
|
||||
"ipv4": "bg.tox.dcntrlzd.network",
|
||||
"ipv6": "bg.tox.dcntrlzd.network",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "20AD2A54D70E827302CDF5F11D7C43FA0EC987042C36628E64B2B721A1426E36",
|
||||
"maintainer": "cryptogospod",
|
||||
"location": "BG",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "1000002015",
|
||||
"motd": "BG tox-bootstrapd node, courtesy of DCNTRLZD NETWORK. Get in touch at 03279E64D53B1B71DFB35F4F5568B448B015F467C0C6F73FB52C9CCF86C78A45DB83C24E7DF2",
|
||||
"last_ping": 1667250480
|
||||
},
|
||||
{
|
||||
"ipv4": "46.146.229.184",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "94750E94013586CCD989233A621747E2646F08F31102339452CADCF6DC2A760A",
|
||||
"maintainer": "GS",
|
||||
"location": "RU",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "",
|
||||
"motd": "",
|
||||
"last_ping": 0
|
||||
},
|
||||
{
|
||||
"ipv4": "gt.sot-te.ch",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "F4F4856F1A311049E0262E9E0A160610284B434F46299988A9CB42BD3D494618",
|
||||
"maintainer": "SOT-TECH",
|
||||
"location": "JP",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "1000002018",
|
||||
"motd": "SOT-TECH NPO",
|
||||
"last_ping": 1672337220
|
||||
},
|
||||
{
|
||||
"ipv4": "209.59.144.175",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "214B7FEA63227CAEC5BCBA87F7ABEEDB1A2FF6D18377DD86BF551B8E094D5F1E",
|
||||
"maintainer": "LasersAreGreat",
|
||||
"location": "US",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "",
|
||||
"motd": "",
|
||||
"last_ping": 0
|
||||
},
|
||||
{
|
||||
"ipv4": "rs.tox.dcntrlzd.network",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "FC4BADF62DCAF17168A4E3ACAD5D656CF424EDB5E0C0C2B9D77E509E74BD8F0D",
|
||||
"maintainer": "cryptogospod",
|
||||
"location": "RS",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "",
|
||||
"motd": "",
|
||||
"last_ping": 0
|
||||
},
|
||||
{
|
||||
"ipv4": "195.123.208.139",
|
||||
"ipv6": "2a02:27ac::3ff",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "534A589BA7427C631773D13083570F529238211893640C99D1507300F055FE73",
|
||||
"maintainer": "Cüber",
|
||||
"location": "LV",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "1000002013",
|
||||
"motd": "😺 meow moew",
|
||||
"last_ping": 1672186498
|
||||
},
|
||||
{
|
||||
"ipv4": "208.38.228.104",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "3634666A51CA5BE1579C031BD31B20059280EB7C05406ED466BD9DFA53373271",
|
||||
"maintainer": "LasersAreGreat",
|
||||
"location": "US",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "",
|
||||
"motd": "",
|
||||
"last_ping": 0
|
||||
},
|
||||
{
|
||||
"ipv4": "lunarfire.spdns.org",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "E61F5963268A6306CCFE7AF98716345235763529957BD5F45889484654EE052B",
|
||||
"maintainer": "Merlinoz",
|
||||
"location": "DE",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "",
|
||||
"motd": "",
|
||||
"last_ping": 0
|
||||
},
|
||||
{
|
||||
"ipv4": "ru.tox.dcntrlzd.network",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "DBB2E896990ECC383DA2E68A01CA148105E34F9B3B9356F2FE2B5096FDB62762",
|
||||
"maintainer": "cryptogospod",
|
||||
"location": "RU",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "1000002015",
|
||||
"motd": "RU tox-bootstrapd node, courtesy of DCNTRLZD NETWORK. Get in touch @ 03279E64D53B1B71DFB35F4F5568B448B015F467C0C6F73FB52C9CCF86C78A45DB83C24E7DF2",
|
||||
"last_ping": 1666732500
|
||||
},
|
||||
{
|
||||
"ipv4": "43.231.185.239",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "27D4029A96C9674C15B958011C62F63D4D35A23142EF2BA5CD9AF164162B3448",
|
||||
"maintainer": "Jskmm",
|
||||
"location": "US",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "",
|
||||
"motd": "",
|
||||
"last_ping": 0
|
||||
},
|
||||
{
|
||||
"ipv4": "141.95.108.234",
|
||||
"ipv6": "-",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "2DEF3156812324B1593A6442C937EAE0A8BD98DE529D2D4A7DD4BA6CB3ECF262",
|
||||
"maintainer": "CTL.DPC.RE",
|
||||
"location": "DE",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "1000002013",
|
||||
"motd": "tox-bootstrapd",
|
||||
"last_ping": 1661962379
|
||||
},
|
||||
{
|
||||
"ipv4": "NONE",
|
||||
"ipv6": "200:832f:2e56:91a6:678e:aaaf:80bf:4a8a",
|
||||
"port": 33445,
|
||||
"tcp_ports": [],
|
||||
"public_key": "444361B1717AD5E10D9C03EA1C714A846C9D3B16A875186D0034DC516A49F013",
|
||||
"maintainer": "Dima(Yggdrasil)",
|
||||
"location": "RU",
|
||||
"status_udp": false,
|
||||
"status_tcp": false,
|
||||
"version": "",
|
||||
"motd": "",
|
||||
"last_ping": 0
|
||||
}
|
||||
]
|
||||
}
|
567
local_pod_repo/objcTox/Classes/Public/Wrapper/OCTTox.h
Normal file
567
local_pod_repo/objcTox/Classes/Public/Wrapper/OCTTox.h
Normal file
@ -0,0 +1,567 @@
|
||||
// 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 "OCTToxDelegate.h"
|
||||
#import "OCTToxConstants.h"
|
||||
|
||||
@class OCTToxOptions;
|
||||
|
||||
@interface OCTTox : NSObject
|
||||
|
||||
@property (weak, nonatomic) id<OCTToxDelegate> delegate;
|
||||
|
||||
/**
|
||||
* Indicates if we are connected to the DHT.
|
||||
*/
|
||||
@property (assign, nonatomic, readonly) OCTToxConnectionStatus connectionStatus;
|
||||
|
||||
/**
|
||||
* Our address.
|
||||
*
|
||||
* Address for Tox as a hex string. Address is kOCTToxAddressLength length and has following format:
|
||||
* [publicKey (32 bytes, 64 characters)][nospam number (4 bytes, 8 characters)][checksum (2 bytes, 4 characters)]
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) NSString *userAddress;
|
||||
|
||||
/**
|
||||
* Our Tox Public Key (long term public key) of kOCTToxPublicKeyLength.
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) NSString *publicKey;
|
||||
|
||||
/**
|
||||
* Our secret key of kOCTToxSecretKeyLength.
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) NSString *secretKey;
|
||||
|
||||
/**
|
||||
* Client's nospam part of the address. Any 32 bit unsigned integer.
|
||||
*/
|
||||
@property (assign, nonatomic) OCTToxNoSpam nospam;
|
||||
|
||||
/**
|
||||
* Client's capabilities. A 64 bit unsigned integer.
|
||||
*/
|
||||
@property (nonatomic, readonly) OCTToxCapabilities capabilities;
|
||||
|
||||
/**
|
||||
* Client's user status.
|
||||
*/
|
||||
@property (assign, nonatomic) OCTToxUserStatus userStatus;
|
||||
|
||||
#pragma mark - Class methods
|
||||
|
||||
/**
|
||||
* Return toxcore version in format X.Y.Z, where
|
||||
* X - The major version number. Incremented when the API or ABI changes in an incompatible way.
|
||||
* Y - The minor version number. Incremented when functionality is added without breaking the API or ABI.
|
||||
* Set to 0 when the major version number is incremented.
|
||||
* Z - The patch or revision number. Incremented when bugfixes are applied without changing any functionality or API or ABI.
|
||||
*/
|
||||
+ (NSString *)version;
|
||||
|
||||
/**
|
||||
* The major version number of toxcore. Incremented when the API or ABI changes in an incompatible way.
|
||||
*/
|
||||
+ (NSUInteger)versionMajor;
|
||||
|
||||
/**
|
||||
* The minor version number of toxcore. Incremented when functionality is added without breaking the API or ABI.
|
||||
* Set to 0 when the major version number is incremented.
|
||||
*/
|
||||
+ (NSUInteger)versionMinor;
|
||||
|
||||
/**
|
||||
* The patch or revision number of toxcore. Incremented when bugfixes are applied without changing any functionality or API or ABI.
|
||||
*/
|
||||
+ (NSUInteger)versionPatch;
|
||||
|
||||
#pragma mark - Lifecycle
|
||||
|
||||
/**
|
||||
* Creates new Tox object with configuration options and loads saved data.
|
||||
*
|
||||
* @param options Configuration options.
|
||||
* @param data Data load Tox from previously stored by `-save` method. Pass nil if there is no saved data.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorInitCode for all error codes.
|
||||
*
|
||||
* @return New instance of Tox or nil if fatal error occured during loading.
|
||||
*
|
||||
* @warning If loading failed or succeeded only partially, the new or partially loaded instance is returned and
|
||||
* an error is set.
|
||||
*/
|
||||
- (instancetype)initWithOptions:(OCTToxOptions *)options savedData:(NSData *)data error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Saves Tox into NSData.
|
||||
*
|
||||
* @return NSData with Tox save.
|
||||
*/
|
||||
- (NSData *)save;
|
||||
|
||||
/**
|
||||
* Starts the main loop of the Tox on it's own unique queue.
|
||||
*
|
||||
* @warning Tox won't do anything without calling this method.
|
||||
*/
|
||||
- (void)start;
|
||||
|
||||
/**
|
||||
* Stops the main loop of the Tox.
|
||||
*/
|
||||
- (void)stop;
|
||||
|
||||
#pragma mark - Methods
|
||||
|
||||
/**
|
||||
* Sends a "get nodes" request to the given bootstrap node with IP, port, and
|
||||
* public key to setup connections.
|
||||
*
|
||||
* This function will attempt to connect to the node using UDP and TCP at the
|
||||
* same time.
|
||||
*
|
||||
* Tox will use the node as a TCP relay in case OCTToxOptions.UDPEnabled was
|
||||
* YES, and also to connect to friends that are in TCP-only mode. Tox will
|
||||
* also use the TCP connection when NAT hole punching is slow, and later switch
|
||||
* to UDP if hole punching succeeds.
|
||||
*
|
||||
* @param host The hostname or an IP address (IPv4 or IPv6) of the node.
|
||||
* @param port The port on the host on which the bootstrap Tox instance is listening.
|
||||
* @param publicKey Public key of the node (of kOCTToxPublicKeyLength length).
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorBootstrapCode for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)bootstrapFromHost:(NSString *)host port:(OCTToxPort)port publicKey:(NSString *)publicKey error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Adds additional host:port pair as TCP relay.
|
||||
*
|
||||
* This function can be used to initiate TCP connections to different ports on
|
||||
* the same bootstrap node, or to add TCP relays without using them as
|
||||
* bootstrap nodes.
|
||||
*
|
||||
* @param host The hostname or IP address (IPv4 or IPv6) of the TCP relay.
|
||||
* @param port The port on the host on which the TCP relay is listening.
|
||||
* @param publicKey Public key of the node (of kOCTToxPublicKeyLength length).
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorBootstrapCode for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)addTCPRelayWithHost:(NSString *)host port:(OCTToxPort)port publicKey:(NSString *)publicKey error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Add a friend.
|
||||
*
|
||||
* @param address Address of a friend to add. Must be exactry kOCTToxAddressLength length.
|
||||
* @param message Message that would be send with friend request. Minimum length - 1 byte.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFriendAdd for all error codes.
|
||||
*
|
||||
* @return On success returns friend number. On failure returns kOCTToxFriendNumberFailure and fills `error` parameter.
|
||||
*
|
||||
* @warning You can check maximum length of message with `-checkLengthOfString:withCheckType:` method with
|
||||
* OCTToxCheckLengthTypeFriendRequest type.
|
||||
*/
|
||||
- (OCTToxFriendNumber)addFriendWithAddress:(NSString *)address message:(NSString *)message error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Add a friend without sending friend request.
|
||||
*
|
||||
* This function is used to add a friend in response to a friend request. If the
|
||||
* client receives a friend request, it can be reasonably sure that the other
|
||||
* client added this client as a friend, eliminating the need for a friend
|
||||
* request.
|
||||
*
|
||||
* This function is also useful in a situation where both instances are
|
||||
* controlled by the same entity, so that this entity can perform the mutual
|
||||
* friend adding. In this case, there is no need for a friend request, either.
|
||||
*
|
||||
* @param publicKey Public key of a friend to add. Public key is hex string, must be exactry kOCTToxPublicKeyLength length.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFriendAdd for all error codes.
|
||||
*
|
||||
* @return On success returns friend number. On failure returns kOCTToxFriendNumberFailure.
|
||||
*/
|
||||
- (OCTToxFriendNumber)addFriendWithNoRequestWithPublicKey:(NSString *)publicKey error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Remove a friend from the friend list.
|
||||
*
|
||||
* This does not notify the friend of their deletion. After calling this
|
||||
* function, this client will appear offline to the friend and no communication
|
||||
* can occur between the two.
|
||||
*
|
||||
* @param friendNumber Friend number to remove.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFriendDelete for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)deleteFriendWithFriendNumber:(OCTToxFriendNumber)friendNumber error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Return the friend number associated with that Public Key.
|
||||
*
|
||||
* @param publicKey Public key of a friend. Public key is hex string, must be exactry kOCTToxPublicKeyLength length.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFriendByPublicKey for all error codes.
|
||||
*
|
||||
* @return The friend number on success, kOCTToxFriendNumberFailure on failure.
|
||||
*/
|
||||
- (OCTToxFriendNumber)friendNumberWithPublicKey:(NSString *)publicKey error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Get public key from associated friend number.
|
||||
*
|
||||
* @param friendNumber Associated friend number
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFriendGetPublicKey for all error codes.
|
||||
*
|
||||
* @return Public key of a friend. Public key is hex string, must be exactry kOCTToxPublicKeyLength length. If there is no such friend returns nil.
|
||||
*/
|
||||
- (NSString *)publicKeyFromFriendNumber:(OCTToxFriendNumber)friendNumber error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Checks if there exists a friend with given friendNumber.
|
||||
*
|
||||
* @param friendNumber Friend number to check.
|
||||
*
|
||||
* @return YES if friend exists, NO otherwise.
|
||||
*/
|
||||
- (BOOL)friendExistsWithFriendNumber:(OCTToxFriendNumber)friendNumber;
|
||||
|
||||
/**
|
||||
* Return a date of the last time the friend associated with a given friend number was seen online.
|
||||
*
|
||||
* @param friendNumber The friend number you want to query.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFriendGetLastOnline for all error codes.
|
||||
*
|
||||
* @return Date of the last time friend was seen online.
|
||||
*/
|
||||
- (NSDate *)friendGetLastOnlineWithFriendNumber:(OCTToxFriendNumber)friendNumber error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Return Friend's capabilities. A 64 bit unsigned integer.
|
||||
*/
|
||||
- (OCTToxCapabilities)friendGetCapabilitiesWithFriendNumber:(OCTToxFriendNumber)friendNumber;
|
||||
|
||||
/**
|
||||
* Return the friend's user status (away/busy/...). If the friend number is
|
||||
* invalid, the return value is unspecified.
|
||||
*
|
||||
* @param friendNumber Friend number to check status.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFriendQuery for all error codes.
|
||||
*
|
||||
* @return Returns friend status.
|
||||
*/
|
||||
- (OCTToxUserStatus)friendStatusWithFriendNumber:(OCTToxFriendNumber)friendNumber error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Check whether a friend is currently connected to this client.
|
||||
*
|
||||
* @param friendNumber Friend number to check status.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFriendQuery for all error codes.
|
||||
*
|
||||
* @return Returns friend connection status.
|
||||
*/
|
||||
- (OCTToxConnectionStatus)friendConnectionStatusWithFriendNumber:(OCTToxFriendNumber)friendNumber error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Send a custom lossless bytes to an online friend.
|
||||
*
|
||||
* @param friendNumber Friend number to send the bytes.
|
||||
* @param pktid the Tox Packet ID.
|
||||
* @param data String that will be converted into bytes using UTF-8 encoding.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)sendLosslessPacketWithFriendNumber:(OCTToxFriendNumber)friendNumber
|
||||
pktid:(uint8_t)pktid
|
||||
data:(NSString *)data
|
||||
error:(NSError **)error;
|
||||
/**
|
||||
* Send a text chat message to an online friend.
|
||||
*
|
||||
* @param friendNumber Friend number to send a message.
|
||||
* @param type Type of the message.
|
||||
* @param message Message that would be send.
|
||||
* @param msgv3HashHex the messagev3 Hash Hexstring or nil.
|
||||
* @param msgv3tssec the messagev3 sendtimestamp in unixtimestamp or "0" if not used.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFriendSendMessage for all error codes.
|
||||
*
|
||||
* @return The message id. Message IDs are unique per friend. The first message ID is 0. Message IDs are
|
||||
* incremented by 1 each time a message is sent. If UINT32_MAX messages were sent, the next message ID is 0.
|
||||
*
|
||||
* @warning You can check maximum length of message with `-checkLengthOfString:withCheckType:` method with
|
||||
* OCTToxCheckLengthTypeSendMessage type.
|
||||
*/
|
||||
- (OCTToxMessageId)sendMessageWithFriendNumber:(OCTToxFriendNumber)friendNumber
|
||||
type:(OCTToxMessageType)type
|
||||
message:(NSString *)message
|
||||
msgv3HashHex:(NSString *)msgv3HashHex
|
||||
msgv3tssec:(UInt32)msgv3tssec
|
||||
error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Set the nickname for the Tox client.
|
||||
*
|
||||
* @param name Name to be set. Minimum length of name is 1 byte.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorSetInfoCode for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*
|
||||
* @warning You can check maximum length of message with `-checkLengthOfString:withCheckType:` method with
|
||||
* OCTToxCheckLengthTypeName type.
|
||||
*/
|
||||
- (BOOL)setNickname:(NSString *)name error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Get your nickname.
|
||||
*
|
||||
* @return Your nickname or nil in case of error.
|
||||
*/
|
||||
- (NSString *)userName;
|
||||
|
||||
/**
|
||||
* Get name of friendNumber.
|
||||
*
|
||||
* @param friendNumber Friend number to get name.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFriendQuery for all error codes.
|
||||
*
|
||||
* @return Name of friend or nil in case of error.
|
||||
*/
|
||||
- (NSString *)friendNameWithFriendNumber:(OCTToxFriendNumber)friendNumber error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Set our status message.
|
||||
*
|
||||
* @param statusMessage Status message to be set.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorSetInfoCode for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*
|
||||
* @warning You can check maximum length of message with `-checkLengthOfString:withCheckType:` method with
|
||||
* OCTToxCheckLengthTypeStatusMessage type.
|
||||
*/
|
||||
- (BOOL)setUserStatusMessage:(NSString *)statusMessage error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Get our status message.
|
||||
*
|
||||
* @return Our status message.
|
||||
*/
|
||||
- (NSString *)userStatusMessage;
|
||||
|
||||
/**
|
||||
* Get status message of a friend.
|
||||
*
|
||||
* @param friendNumber Friend number to get status message.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFriendQuery for all error codes.
|
||||
*
|
||||
* @return Status message of a friend.
|
||||
*/
|
||||
- (NSString *)friendStatusMessageWithFriendNumber:(OCTToxFriendNumber)friendNumber error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Set our typing status for a friend. You are responsible for turning it on or off.
|
||||
*
|
||||
* @param isTyping Status showing whether user is typing or not.
|
||||
* @param friendNumber Friend number to set typing status.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorSetTyping for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)setUserIsTyping:(BOOL)isTyping forFriendNumber:(OCTToxFriendNumber)friendNumber error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Get the typing status of a friend.
|
||||
*
|
||||
* @param friendNumber Friend number to get typing status.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFriendQuery for all error codes.
|
||||
*
|
||||
* @return YES if friend is typing, otherwise NO.
|
||||
*/
|
||||
- (BOOL)isFriendTypingWithFriendNumber:(OCTToxFriendNumber)friendNumber error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Return the number of friends.
|
||||
*
|
||||
* @return Return the number of friends.
|
||||
*/
|
||||
- (NSUInteger)friendsCount;
|
||||
|
||||
/**
|
||||
* Return an array of valid friend IDs.
|
||||
*
|
||||
* @return Return an array of valid friend IDs. Array contain NSNumbers with IDs.
|
||||
*/
|
||||
- (NSArray *)friendsArray;
|
||||
|
||||
/**
|
||||
* Generates a cryptographic hash of the given data.
|
||||
* This function may be used by clients for any purpose, but is provided primarily for
|
||||
* validating cached avatars. This use is highly recommended to avoid unnecessary avatar
|
||||
* updates.
|
||||
*
|
||||
* @param data Data to be hashed
|
||||
*
|
||||
* @return Hash generated from data.
|
||||
*/
|
||||
- (NSData *)hashData:(NSData *)data;
|
||||
|
||||
/**
|
||||
* Sends a file control command to a friend for a given file transfer.
|
||||
*
|
||||
* @param fileNumber The friend-specific identifier for the file transfer.
|
||||
* @param friendNumber The friend number of the friend the file is being transferred to or received from.
|
||||
* @param control The control command to send.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFileControl for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)fileSendControlForFileNumber:(OCTToxFileNumber)fileNumber
|
||||
friendNumber:(OCTToxFriendNumber)friendNumber
|
||||
control:(OCTToxFileControl)control
|
||||
error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Sends a file seek control command to a friend for a given file transfer.
|
||||
*
|
||||
* This function can only be called to resume a file transfer right before
|
||||
* OCTToxFileControlResume is sent.
|
||||
*
|
||||
* @param fileNumber The friend-specific identifier for the file transfer.
|
||||
* @param friendNumber The friend number of the friend the file is being received from.
|
||||
* @param position The position that the file should be seeked to.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFileSeek for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)fileSeekForFileNumber:(OCTToxFileNumber)fileNumber
|
||||
friendNumber:(OCTToxFriendNumber)friendNumber
|
||||
position:(OCTToxFileSize)position
|
||||
error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Get the file id associated to the file transfer.
|
||||
*
|
||||
* @param fileNumber The friend-specific identifier for the file transfer.
|
||||
* @param friendNumber The friend number of the friend the file is being transferred to or received from.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFileGet for all error codes.
|
||||
*
|
||||
* @return File id on success, nil on failure.
|
||||
*/
|
||||
- (NSData *)fileGetFileIdForFileNumber:(OCTToxFileNumber)fileNumber
|
||||
friendNumber:(OCTToxFriendNumber)friendNumber
|
||||
error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Send a file transmission request.
|
||||
*
|
||||
* Maximum filename length is kOCTToxMaxFileNameLength bytes. The filename should generally just be
|
||||
* a file name, not a path with directory names.
|
||||
*
|
||||
* If a non-zero file size is provided, this can be used by both sides to
|
||||
* determine the sending progress. File size can be set to zero for streaming
|
||||
* data of unknown size.
|
||||
*
|
||||
* File transmission occurs in chunks, which are requested through the
|
||||
* `fileChunkRequest` callback.
|
||||
*
|
||||
* When a friend goes offline, all file transfers associated with the friend are
|
||||
* purged from core.
|
||||
*
|
||||
* If the file contents change during a transfer, the behaviour is unspecified
|
||||
* in general. What will actually happen depends on the mode in which the file
|
||||
* was modified and how the client determines the file size.
|
||||
*
|
||||
* - If the file size was increased
|
||||
* - and sending mode was streaming (fileSize = kOCTToxFileSizeUnknown), the behaviour will be as
|
||||
* expected.
|
||||
* - and sending mode was file (fileSize != kOCTToxFileSizeUnknown), the fileChunkRequest
|
||||
* callback will receive length = 0 when Core thinks the file transfer has
|
||||
* finished. If the client remembers the file size as it was when sending
|
||||
* the request, it will terminate the transfer normally. If the client
|
||||
* re-reads the size, it will think the friend cancelled the transfer.
|
||||
* - If the file size was decreased
|
||||
* - and sending mode was streaming, the behaviour is as expected.
|
||||
* - and sending mode was file, the callback will return 0 at the new
|
||||
* (earlier) end-of-file, signalling to the friend that the transfer was
|
||||
* cancelled.
|
||||
* - If the file contents were modified
|
||||
* - at a position before the current read, the two files (local and remote)
|
||||
* will differ after the transfer terminates.
|
||||
* - at a position after the current read, the file transfer will succeed as
|
||||
* expected.
|
||||
* - In either case, both sides will regard the transfer as complete and
|
||||
* successful.
|
||||
*
|
||||
* @param friendNumber The friend number of the friend the file send request should be sent to.
|
||||
* @param kind The meaning of the file to be sent.
|
||||
* @param fileSize Size in bytes of the file the client wants to send, kOCTToxFileSizeUnknown if unknown or streaming.
|
||||
* @param fileId A file identifier of length kOCTToxFileIdLength that can be used to
|
||||
* uniquely identify file transfers across core restarts. If nil, a random one will
|
||||
* be generated by core. It can then be obtained by using `fileGetFileId`.
|
||||
* @param fileName Name of the file. Does not need to be the actual name. This
|
||||
* name will be sent along with the file send request.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFileSend for all error codes.
|
||||
*
|
||||
* @return A file number used as an identifier in subsequent callbacks. This
|
||||
* number is per friend. File numbers are reused after a transfer terminates.
|
||||
* on failure, this function returns kOCTToxFileNumberFailure.
|
||||
*/
|
||||
- (OCTToxFileNumber)fileSendWithFriendNumber:(OCTToxFriendNumber)friendNumber
|
||||
kind:(OCTToxFileKind)kind
|
||||
fileSize:(OCTToxFileSize)fileSize
|
||||
fileId:(NSData *)fileId
|
||||
fileName:(NSString *)fileName
|
||||
error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Send a chunk of file data to a friend.
|
||||
*
|
||||
* This method is called in response to the `fileChunkRequest` callback. The
|
||||
* length of data should be equal to the one received though the callback.
|
||||
* If it is zero, the transfer is assumed complete. For files with known size,
|
||||
* Core will know that the transfer is complete after the last byte has been
|
||||
* received, so it is not necessary (though not harmful) to send a zero-length
|
||||
* chunk to terminate. For streams, core will know that the transfer is finished
|
||||
* if a chunk with length less than the length requested in the callback is sent.
|
||||
*
|
||||
* @param friendNumber The friend number of the receiving friend for this file.
|
||||
* @param fileNumber The file transfer identifier returned by fileSend.
|
||||
* @param position The file or stream position from which to continue reading.
|
||||
* @param data Data of chunk to send. May be nil, then transfer is assumed complete.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxErrorFileSendChunk for all error codes.
|
||||
*
|
||||
* @return YES on success, NO on failure.
|
||||
*/
|
||||
- (BOOL)fileSendChunkForFileNumber:(OCTToxFileNumber)fileNumber
|
||||
friendNumber:(OCTToxFriendNumber)friendNumber
|
||||
position:(OCTToxFileSize)position
|
||||
data:(NSData *)data
|
||||
error:(NSError **)error;
|
||||
|
||||
@end
|
148
local_pod_repo/objcTox/Classes/Public/Wrapper/OCTToxAV.h
Normal file
148
local_pod_repo/objcTox/Classes/Public/Wrapper/OCTToxAV.h
Normal file
@ -0,0 +1,148 @@
|
||||
// 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 "OCTToxAVConstants.h"
|
||||
#import "OCTToxConstants.h"
|
||||
#import "OCTToxAVDelegate.h"
|
||||
|
||||
@class OCTTox;
|
||||
|
||||
@interface OCTToxAV : NSObject
|
||||
|
||||
@property (weak, nonatomic) id<OCTToxAVDelegate> delegate;
|
||||
|
||||
#pragma mark - Lifecycle
|
||||
|
||||
/**
|
||||
* Creates a new Toxav object.
|
||||
* @param tox Tox object to be initialized with.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object.
|
||||
*/
|
||||
- (instancetype)initWithTox:(OCTTox *)tox error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Starts the main loop of the ToxAV on it's own unique queue.
|
||||
*
|
||||
* @warning ToxAV won't do anything without calling this method.
|
||||
*/
|
||||
- (void)start;
|
||||
|
||||
/**
|
||||
* Stops the main loop of the ToxAV.
|
||||
*/
|
||||
- (void)stop;
|
||||
|
||||
#pragma mark - Call Methods
|
||||
|
||||
/**
|
||||
* Call a friend. This will start ringing the friend.
|
||||
* It is the client's responsibility to stop ringing after a certain timeout,
|
||||
* if such behaviour is desired. If the client does not stop ringing, the
|
||||
* library will not stop until the friend is disconnected.
|
||||
* @param friendNumber The friend number of the friend that should be called.
|
||||
* @param audioBitRate Audio bit rate in Kb/sec. Set this to kOCTToxAVAudioBitRateDisable to disable audio sending.
|
||||
* @param videoBitRate Video bit rate in Kb/sec. Set this to kOCTToxAVVideoBitRateDisable to disable video sending.
|
||||
* video sending.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object.
|
||||
*/
|
||||
- (BOOL)callFriendNumber:(OCTToxFriendNumber)friendNumber audioBitRate:(OCTToxAVAudioBitRate)audioBitRate videoBitRate:(OCTToxAVVideoBitRate)videoBitRate error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Accept an incoming call.
|
||||
*
|
||||
* If answering fails for any reason, the call will still be pending and it is
|
||||
* possible to try and answer it later.
|
||||
*
|
||||
* @param friendNumber The friend number of the friend that is calling.
|
||||
* @param audioBitRate Audio bit rate in Kb/sec. Set this to kOCTToxAVAudioBitRateDisable to disable
|
||||
* audio sending.
|
||||
* @param videoBitRate Video bit rate in Kb/sec. Set this to kOCTToxAVVideoBitRateDisable to disable
|
||||
* video sending.
|
||||
*/
|
||||
- (BOOL)answerIncomingCallFromFriend:(OCTToxFriendNumber)friendNumber audioBitRate:(OCTToxAVAudioBitRate)audioBitRate videoBitRate:(OCTToxAVVideoBitRate)videoBitrate error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Send a call control to a friend
|
||||
* @param control The control command to send.
|
||||
* @param friendNumber The friend number of the friend this client is in a call with.
|
||||
*/
|
||||
- (BOOL)sendCallControl:(OCTToxAVCallControl)control toFriendNumber:(OCTToxFriendNumber)friendNumber error:(NSError **)error;
|
||||
|
||||
#pragma mark - Controlling bit rates
|
||||
/**
|
||||
* Set the audio bit rate to be used in subsequent audio frames. If the passed
|
||||
* bit rate is the same as the current bit rate this function will return true
|
||||
* without calling a callback. If there is an active non forceful setup with the
|
||||
* passed audio bit rate and the new set request is forceful, the bit rate is
|
||||
* forcefully set and the previous non forceful request is cancelled. The active
|
||||
* non forceful setup will be canceled in favour of new non forceful setup.
|
||||
* @param bitRate The new audio bit rate in Kb/sec. Set to kOCTToxAVAudioBitRateDisable to disable audio sending.
|
||||
* @param friendNumber The friend for which to set the audio bit rate.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object.
|
||||
*/
|
||||
- (BOOL)setAudioBitRate:(OCTToxAVAudioBitRate)bitRate force:(BOOL)force forFriend:(OCTToxFriendNumber)friendNumber error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Set the video bit rate to be used in subsequent video frames. If the passed
|
||||
* bit rate is the same as the current bit rate this function will return true
|
||||
* without calling a callback. If there is an active non forceful setup with the
|
||||
* passed video bit rate and the new set request is forceful, the bit rate is
|
||||
* forcefully set and the previous non forceful request is cancelled. The active
|
||||
* non forceful setup will be canceled in favour of new non forceful setup.
|
||||
* @param bitRate The new video bit rate in Kb/sec. Set to kOCTToxAVVideoBitRateDisable to disable video sending.
|
||||
* @param friendNumber The friend for which to set the video bit rate.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object.
|
||||
*/
|
||||
- (BOOL)setVideoBitRate:(OCTToxAVVideoBitRate)bitRate force:(BOOL)force forFriend:(OCTToxFriendNumber)friendNumber error:(NSError **)error;
|
||||
|
||||
#pragma mark - Sending frames
|
||||
|
||||
/**
|
||||
* Send an audio frame to a friend.
|
||||
*
|
||||
* The expected format of the PCM data is: [s1c1][s1c2][...][s2c1][s2c2][...]...
|
||||
* Meaning: sample 1 for channel 1, sample 1 for channel 2, ...
|
||||
* For mono audio, this has no meaning, every sample is subsequent. For stereo,
|
||||
* this means the expected format is LRLRLR... with samples for left and right
|
||||
* alternating.
|
||||
* @param pcm An array of audio samples. The size of this array must be
|
||||
* sample_count * channels.
|
||||
* @param sampleCount Number of samples in this frame. Valid numbers here are
|
||||
* ((sample rate) * (audio length) / 1000), where audio length can be
|
||||
* 2.5, 5, 10, 20, 40 or 60 millseconds.
|
||||
* @param channels Number of audio channels. Supported values are 1 and 2.
|
||||
* @param samplingRate Audio sampling rate used in this frame. Valid sampling
|
||||
* rates are 8000, 12000, 16000, 24000, or 48000.
|
||||
* @param friendNumber The friend number of the friend to which to send an
|
||||
* audio frame.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object.
|
||||
*/
|
||||
- (BOOL)sendAudioFrame:(OCTToxAVPCMData *)pcm sampleCount:(OCTToxAVSampleCount)sampleCount
|
||||
channels:(OCTToxAVChannels)channels sampleRate:(OCTToxAVSampleRate)sampleRate
|
||||
toFriend:(OCTToxFriendNumber)friendNumber error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Send a video frame to a friend.
|
||||
*
|
||||
* Y - plane should be of size: height * width
|
||||
* U - plane should be of size: (height/2) * (width/2)
|
||||
* V - plane should be of size: (height/2) * (width/2)
|
||||
*
|
||||
* @param friendNumber The friend number of the friend to which to send a video
|
||||
* frame.
|
||||
* @param width Width of the frame in pixels.
|
||||
* @param height Height of the frame in pixels.
|
||||
* @param y Y (Luminance) plane data.
|
||||
* @param u U (Chroma) plane data.
|
||||
* @param v V (Chroma) plane data.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object.
|
||||
*/
|
||||
- (BOOL)sendVideoFrametoFriend:(OCTToxFriendNumber)friendNumber
|
||||
width:(OCTToxAVVideoWidth)width height:(OCTToxAVVideoHeight)height
|
||||
yPlane:(OCTToxAVPlaneData *)yPlane uPlane:(OCTToxAVPlaneData *)uPlane
|
||||
vPlane:(OCTToxAVPlaneData *)vPlane
|
||||
error:(NSError **)error;
|
||||
@end
|
@ -0,0 +1,339 @@
|
||||
// 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>
|
||||
|
||||
typedef const int16_t OCTToxAVPCMData;
|
||||
typedef size_t OCTToxAVSampleCount;
|
||||
typedef uint8_t OCTToxAVChannels;
|
||||
typedef uint32_t OCTToxAVSampleRate;
|
||||
|
||||
typedef int OCTToxAVVideoBitRate;
|
||||
typedef uint16_t OCTToxAVVideoWidth;
|
||||
typedef uint16_t OCTToxAVVideoHeight;
|
||||
typedef const uint8_t OCTToxAVPlaneData;
|
||||
typedef const int32_t OCTToxAVStrideData;
|
||||
|
||||
extern const OCTToxAVVideoBitRate kOCTToxAVVideoBitRateDisable;
|
||||
|
||||
extern NSString *const kOCTToxAVErrorDomain;
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Call state graph
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
typedef NS_OPTIONS(NSInteger, OCTToxAVCallState) {
|
||||
|
||||
/**
|
||||
* The call is paused by the friend.
|
||||
*/
|
||||
OCTToxAVFriendCallStatePaused = 0,
|
||||
|
||||
/**
|
||||
* Set by the AV core if an error occurred on the remote end or if friend
|
||||
* timed out. This is the final state after which no more state
|
||||
* transitions can occur for the call. This call state will never be triggered
|
||||
* in combination with other call states.
|
||||
*/
|
||||
OCTToxAVFriendCallStateError = 1 << 0,
|
||||
|
||||
/**
|
||||
* The call has finished. This is the final state after which no more state
|
||||
* transitions can occur for the call. This call state will never be
|
||||
* triggered in combination with other call states.
|
||||
*/
|
||||
OCTToxAVFriendCallStateFinished = 1 << 1,
|
||||
|
||||
/**
|
||||
* The flag that marks that friend is sending audio.
|
||||
*/
|
||||
OCTToxAVFriendCallStateSendingAudio = 1 << 2,
|
||||
|
||||
/**
|
||||
* The flag that marks that friend is sending video.
|
||||
*/
|
||||
OCTToxAVFriendCallStateSendingVideo = 1 << 3,
|
||||
|
||||
/**
|
||||
* The flag that marks that friend is accepting audio.
|
||||
*/
|
||||
OCTToxAVFriendCallStateAcceptingAudio = 1 << 4,
|
||||
|
||||
/**
|
||||
* The flag that marks that friend is accepting video.
|
||||
*/
|
||||
OCTToxAVFriendCallStateAcceptingVideo = 1 << 5,
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Error Codes
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Error codes for init method.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxAVErrorInitCode) {
|
||||
OCTToxAVErrorInitCodeUnknown,
|
||||
/**
|
||||
* One of the arguments to the function was NULL when it was not expected.
|
||||
*/
|
||||
OCTToxAVErrorInitNULL,
|
||||
|
||||
/**
|
||||
* Memory allocation failure while trying to allocate structures required for
|
||||
* the A/V session.
|
||||
*/
|
||||
OCTToxAVErrorInitCodeMemoryError,
|
||||
|
||||
/**
|
||||
* Attempted to create a second session for the same Tox instance.
|
||||
*/
|
||||
OCTToxAVErrorInitMultiple,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for call setup.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxAVErrorCall) {
|
||||
OCTToxAVErrorCallUnknown,
|
||||
|
||||
/**
|
||||
* A resource allocation error occurred while trying to create the structures
|
||||
* required for the call.
|
||||
*/
|
||||
OCTToxAVErrorCallMalloc,
|
||||
|
||||
/**
|
||||
* Synchronization error occurred.
|
||||
*/
|
||||
OCTToxAVErrorCallSync,
|
||||
|
||||
/**
|
||||
* The friend number did not designate a valid friend.
|
||||
*/
|
||||
OCTToxAVErrorCallFriendNotFound,
|
||||
|
||||
/**
|
||||
* The friend was valid, but not currently connected.
|
||||
*/
|
||||
OCTToxAVErrorCallFriendNotConnected,
|
||||
|
||||
/**
|
||||
* Attempted to call a friend while already in an audio or video call with
|
||||
* them.
|
||||
*/
|
||||
OCTToxAVErrorCallAlreadyInCall,
|
||||
|
||||
/**
|
||||
* Audio or video bit rate is invalid.
|
||||
*/
|
||||
OCTToxAVErrorCallInvalidBitRate,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for answer calls.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxAVErrorAnswer) {
|
||||
OCTToxAVErrorAnswerUnknown,
|
||||
|
||||
/**
|
||||
* Synchronization error occurred.
|
||||
*/
|
||||
OCTToxAVErrorAnswerSync,
|
||||
|
||||
/**
|
||||
* Failed to initialize codecs for call session. Note that codec initiation
|
||||
* will fail if there is no receive callback registered for either audio or
|
||||
* video.
|
||||
*/
|
||||
OCTToxAVErrorAnswerCodecInitialization,
|
||||
|
||||
/**
|
||||
* The friend number did not designate a valid friend.
|
||||
*/
|
||||
OCTToxAVErrorAnswerFriendNotFound,
|
||||
|
||||
/**
|
||||
* The friend was valid, but they are not currently trying to initiate a call.
|
||||
* This is also returned if this client is already in a call with the friend.
|
||||
*/
|
||||
OCTToxAVErrorAnswerFriendNotCalling,
|
||||
|
||||
/**
|
||||
* Audio or video bit rate is invalid.
|
||||
*/
|
||||
OCTToxAVErrorAnswerInvalidBitRate,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for when sending controls.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorCallControl) {
|
||||
OCTToxAVErrorControlUnknown,
|
||||
|
||||
/**
|
||||
* Synchronization error occurred.
|
||||
*/
|
||||
OCTToxAVErrorControlSync,
|
||||
|
||||
/**
|
||||
* The friend number passed did not designate a valid friend.
|
||||
*/
|
||||
OCTToxAVErrorControlFriendNotFound,
|
||||
|
||||
/**
|
||||
* This client is currently not in a call with the friend. Before the call is
|
||||
* answered, only CANCEL is a valid control.
|
||||
*/
|
||||
OCTToxAVErrorControlFriendNotInCall,
|
||||
|
||||
/**
|
||||
* Happens if user tried to pause an already paused call or if trying to
|
||||
* resume a call that is not paused.
|
||||
*/
|
||||
OCTToxAVErrorControlInvaldTransition,
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for setting the bit rate.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxAVErrorSetBitRate) {
|
||||
OCTToxAVErrorSetBitRateUnknown,
|
||||
|
||||
/**
|
||||
* Synchronization error occured.
|
||||
*/
|
||||
OCTToxAVErrorSetBitRateSync,
|
||||
|
||||
/**
|
||||
* The bit rate passed was not one of the supported values.<Paste>
|
||||
*/
|
||||
OCTToxAVErrorSetBitRateInvalidBitRate,
|
||||
|
||||
/**
|
||||
* The friend number passed did not designate a valid friend.
|
||||
*/
|
||||
OCTToxAVErrorSetBitRateFriendNotFound,
|
||||
|
||||
/**
|
||||
* This client is currently not in a call with the friend.
|
||||
*/
|
||||
OCTToxAVErrorSetBitRateFriendNotInCall,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for sending audio/video frames
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxAVErrorSendFrame) {
|
||||
OCTToxAVErrorSendFrameUnknown,
|
||||
|
||||
/**
|
||||
* In case of video, one of Y, U, or V was NULL. In case of audio, the samples
|
||||
* data pointer was NULL.
|
||||
*/
|
||||
OCTToxAVErrorSendFrameNull,
|
||||
|
||||
/**
|
||||
* The friend number passed did not designate a valid friend.
|
||||
*/
|
||||
OCTToxAVErrorSendFrameFriendNotFound,
|
||||
|
||||
/**
|
||||
* This client is currently not in a call with the friend.
|
||||
*/
|
||||
OCTToxAVErrorSendFrameFriendNotInCall,
|
||||
|
||||
/**
|
||||
* Synchronization error occurred.
|
||||
*/
|
||||
OCTToxAVErrorSendFrameSync,
|
||||
|
||||
/**
|
||||
* One of the frame parameters was invalid. E.g. the resolution may be too
|
||||
* small or too large, or the audio sampling rate may be unsupported.
|
||||
*/
|
||||
OCTToxAVErrorSendFrameInvalid,
|
||||
|
||||
/**
|
||||
* Bit rate for this payload type was not set up.
|
||||
*/
|
||||
OCTToxAVErrorSendFramePayloadTypeDisabled,
|
||||
|
||||
/**
|
||||
* Failed to push frame through rtp interface.
|
||||
*/
|
||||
OCTToxAVErrorSendFrameRTPFailed,
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Call control
|
||||
*
|
||||
******************************************************************************/
|
||||
typedef NS_ENUM(NSInteger, OCTToxAVCallControl) {
|
||||
/**
|
||||
* Resume a previously paused call. Only valid if the pause was caused by this
|
||||
* client, if not, this control is ignored. Not valid before the call is accepted.
|
||||
*/
|
||||
OCTToxAVCallControlResume,
|
||||
|
||||
/**
|
||||
* Put a call on hold. Not valid before the call is accepted.
|
||||
*/
|
||||
OCTToxAVCallControlPause,
|
||||
|
||||
/**
|
||||
* Reject a call if it was not answered, yet. Cancel a call after it was
|
||||
* answered.
|
||||
*/
|
||||
OCTToxAVCallControlCancel,
|
||||
|
||||
/**
|
||||
* Request that the friend stops sending audio. Regardless of the friend's
|
||||
* compliance, this will cause the audio_receive_frame event to stop being
|
||||
* triggered on receiving an audio frame from the friend.
|
||||
*/
|
||||
OCTToxAVCallControlMuteAudio,
|
||||
|
||||
/**
|
||||
* Calling this control will notify client to start sending audio again.
|
||||
*/
|
||||
OCTToxAVCallControlUnmuteAudio,
|
||||
|
||||
/**
|
||||
* Request that the friend stops sending video. Regardless of the friend's
|
||||
* compliance, this will cause the video_receive_frame event to stop being
|
||||
* triggered on receiving an video frame from the friend.
|
||||
*/
|
||||
OCTToxAVCallControlHideVideo,
|
||||
|
||||
/**
|
||||
* Calling this control will notify client to start sending video again.
|
||||
*/
|
||||
OCTToxAVCallControlShowVideo,
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Audio Bitrates. All bitrates are in kb/s.
|
||||
*
|
||||
******************************************************************************/
|
||||
typedef NS_ENUM(NSInteger, OCTToxAVAudioBitRate) {
|
||||
OCTToxAVAudioBitRateDisabled = 0,
|
||||
|
||||
OCTToxAVAudioBitRate8 = 8,
|
||||
|
||||
OCTToxAVAudioBitRate16 = 16,
|
||||
|
||||
OCTToxAVAudioBitRate24 = 24,
|
||||
|
||||
OCTToxAVAudioBitRate32 = 32,
|
||||
|
||||
OCTToxAVAudioBitRate48 = 48,
|
||||
};
|
@ -0,0 +1,95 @@
|
||||
// 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 "OCTToxAVConstants.h"
|
||||
#import "OCTToxConstants.h"
|
||||
|
||||
@class OCTToxAV;
|
||||
|
||||
/**
|
||||
* All delegate methods will be called on main thread.
|
||||
*/
|
||||
@protocol OCTToxAVDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
/**
|
||||
* Receiving call from friend.
|
||||
* @param audio YES audio is enabled. NO otherwise.
|
||||
* @param video YES video is enabled. NO otherwise.
|
||||
* @param friendNumber Friend number who is calling.
|
||||
*/
|
||||
- (void)toxAV:(OCTToxAV *)toxAV receiveCallAudioEnabled:(BOOL)audio videoEnabled:(BOOL)video friendNumber:(OCTToxFriendNumber)friendNumber;
|
||||
|
||||
/**
|
||||
* Call state has changed.
|
||||
* @param state The new state.
|
||||
* @param friendNumber Friend number whose state has changed.
|
||||
*/
|
||||
- (void)toxAV:(OCTToxAV *)toxAV callStateChanged:(OCTToxAVCallState)state friendNumber:(OCTToxFriendNumber)friendNumber;
|
||||
|
||||
/**
|
||||
* The event is triggered when the network becomes too saturated for
|
||||
* current bit rates at which point core suggests new bit rates.
|
||||
* @param audioBitRate Suggested maximum audio bit rate in Kb/sec.
|
||||
* @param friendNumber The friend number of the friend for which to set the bit rate.
|
||||
*/
|
||||
- (void)toxAV:(OCTToxAV *)toxAV audioBitRateStatus:(OCTToxAVAudioBitRate)audioBitRate forFriendNumber:(OCTToxFriendNumber)friendNumber;
|
||||
|
||||
/**
|
||||
* The event is triggered when the network becomes too saturated for
|
||||
* current bit rates at which point core suggests new bit rates.
|
||||
* @param videoBitRate Suggested maximum video bit rate in Kb/sec.
|
||||
* @param friendNumber The friend number of the friend for which to set the bit rate.
|
||||
*/
|
||||
- (void)toxAV:(OCTToxAV *)toxAV videoBitRateStatus:(OCTToxAVVideoBitRate)videoBitRate forFriendNumber:(OCTToxFriendNumber)friendNumber;
|
||||
|
||||
/**
|
||||
* Received audio frame from friend.
|
||||
* @param pcm An array of audio samples (sample_count * channels elements).
|
||||
* @param sampleCount The number of audio samples per channel in the PCM array.
|
||||
* @param channels Number of audio channels.
|
||||
* @param sampleRate Sampling rate used in this frame.
|
||||
* @param friendNumber The friend number of the friend who sent an audio frame.
|
||||
*/
|
||||
|
||||
- (void) toxAV:(OCTToxAV *)toxAV
|
||||
receiveAudio:(OCTToxAVPCMData *)pcm
|
||||
sampleCount:(OCTToxAVSampleCount)sampleCount
|
||||
channels:(OCTToxAVChannels)channels
|
||||
sampleRate:(OCTToxAVSampleRate)sampleRate
|
||||
friendNumber:(OCTToxFriendNumber)friendNumber;
|
||||
|
||||
/**
|
||||
* Received video frame from friend.
|
||||
* @param width Width of the frame in pixels.
|
||||
* @param height Height of the frame in pixels.
|
||||
* @param yPlane
|
||||
* @param uPlane
|
||||
* @param vPlane Plane data.
|
||||
* The size of plane data is derived from width and height where
|
||||
* Y = MAX(width, abs(ystride)) * height,
|
||||
* U = MAX(width/2, abs(ustride)) * (height/2) and
|
||||
* V = MAX(width/2, abs(vstride)) * (height/2).
|
||||
* @param yStride
|
||||
* @param uStride
|
||||
* @param vStride Strides data. Strides represent padding for each plane
|
||||
* that may or may not be present. You must handle strides in
|
||||
* your image processing code. Strides are negative if the
|
||||
* image is bottom-up hence why you MUST abs() it when
|
||||
* calculating plane buffer size.
|
||||
* @param friendNumber The friend number of the friend who sent an audio frame.
|
||||
*/
|
||||
|
||||
- (void) toxAV:(OCTToxAV *)toxAV
|
||||
receiveVideoFrameWithWidth:(OCTToxAVVideoWidth)width height:(OCTToxAVVideoHeight)height
|
||||
yPlane:(OCTToxAVPlaneData *)yPlane uPlane:(OCTToxAVPlaneData *)uPlane
|
||||
vPlane:(OCTToxAVPlaneData *)vPlane
|
||||
yStride:(OCTToxAVStrideData)yStride uStride:(OCTToxAVStrideData)uStride
|
||||
vStride:(OCTToxAVStrideData)vStride
|
||||
friendNumber:(OCTToxFriendNumber)friendNumber;
|
||||
|
||||
@end
|
557
local_pod_repo/objcTox/Classes/Public/Wrapper/OCTToxConstants.h
Normal file
557
local_pod_repo/objcTox/Classes/Public/Wrapper/OCTToxConstants.h
Normal file
@ -0,0 +1,557 @@
|
||||
// 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>
|
||||
|
||||
typedef uint32_t OCTToxNoSpam;
|
||||
typedef uint16_t OCTToxPort;
|
||||
typedef int OCTToxFriendNumber;
|
||||
typedef int OCTToxMessageId;
|
||||
typedef uint32_t OCTToxFileNumber;
|
||||
typedef long long OCTToxFileSize;
|
||||
typedef uint64_t OCTToxCapabilities;
|
||||
|
||||
extern const OCTToxFriendNumber kOCTToxFriendNumberFailure;
|
||||
extern const OCTToxFileNumber kOCTToxFileNumberFailure;
|
||||
extern const OCTToxFileSize kOCTToxFileSizeUnknown;
|
||||
|
||||
extern NSString *const kOCTToxErrorDomain;
|
||||
|
||||
/**
|
||||
* Length of address. Address is hex string, has following format:
|
||||
* [publicKey (32 bytes, 64 characters)][nospam number (4 bytes, 8 characters)][checksum (2 bytes, 4 characters)]
|
||||
*/
|
||||
extern const NSUInteger kOCTToxAddressLength;
|
||||
|
||||
/**
|
||||
* Length of public key. It is hex string, 32 bytes, 64 characters.
|
||||
*/
|
||||
extern const NSUInteger kOCTToxPublicKeyLength;
|
||||
/**
|
||||
* Length of secret key. It is hex string, 32 bytes, 64 characters.
|
||||
*/
|
||||
extern const NSUInteger kOCTToxSecretKeyLength;
|
||||
|
||||
extern const NSUInteger kOCTToxMaxNameLength;
|
||||
extern const NSUInteger kOCTToxMaxStatusMessageLength;
|
||||
extern const NSUInteger kOCTToxMaxFriendRequestLength;
|
||||
extern const NSUInteger kOCTToxMaxMessageLength;
|
||||
extern const NSUInteger kOCTToxMaxCustomPacketSize;
|
||||
extern const NSUInteger kOCTToxMaxFileNameLength;
|
||||
|
||||
extern const NSUInteger kOCTToxHashLength;
|
||||
extern const NSUInteger kOCTToxFileIdLength;
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTToxProxyType) {
|
||||
OCTToxProxyTypeNone,
|
||||
OCTToxProxyTypeSocks5,
|
||||
OCTToxProxyTypeHTTP,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTToxConnectionStatus) {
|
||||
/**
|
||||
* There is no connection. This instance, or the friend the state change is about, is now offline.
|
||||
*/
|
||||
OCTToxConnectionStatusNone,
|
||||
|
||||
/**
|
||||
* A TCP connection has been established. For the own instance, this means it
|
||||
* is connected through a TCP relay, only. For a friend, this means that the
|
||||
* connection to that particular friend goes through a TCP relay.
|
||||
*/
|
||||
OCTToxConnectionStatusTCP,
|
||||
|
||||
/**
|
||||
* A UDP connection has been established. For the own instance, this means it
|
||||
* is able to send UDP packets to DHT nodes, but may still be connected to
|
||||
* a TCP relay. For a friend, this means that the connection to that
|
||||
* particular friend was built using direct UDP packets.
|
||||
*/
|
||||
OCTToxConnectionStatusUDP,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTToxUserStatus) {
|
||||
/**
|
||||
* User is online and available.
|
||||
*/
|
||||
OCTToxUserStatusNone,
|
||||
/**
|
||||
* User is away. Clients can set this e.g. after a user defined
|
||||
* inactivity time.
|
||||
*/
|
||||
OCTToxUserStatusAway,
|
||||
/**
|
||||
* User is busy. Signals to other clients that this client does not
|
||||
* currently wish to communicate.
|
||||
*/
|
||||
OCTToxUserStatusBusy,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTToxMessageType) {
|
||||
/**
|
||||
* Normal text message. Similar to PRIVMSG on IRC.
|
||||
*/
|
||||
OCTToxMessageTypeNormal,
|
||||
/**
|
||||
* A message describing an user action. This is similar to /me (CTCP ACTION)
|
||||
* on IRC.
|
||||
*/
|
||||
OCTToxMessageTypeAction,
|
||||
/**
|
||||
* msgV3 HIGH LEVEL ACK message.
|
||||
*/
|
||||
OCTToxMessageTypeHighlevelack,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTToxFileKind) {
|
||||
/**
|
||||
* Arbitrary file data. Clients can choose to handle it based on the file name
|
||||
* or magic or any other way they choose.
|
||||
*/
|
||||
OCTToxFileKindData,
|
||||
|
||||
/**
|
||||
* Avatar filename. This consists of toxHash(image).
|
||||
* Avatar data. This consists of the image data.
|
||||
*
|
||||
* Avatars can be sent at any time the client wishes. Generally, a client will
|
||||
* send the avatar to a friend when that friend comes online, and to all
|
||||
* friends when the avatar changed. A client can save some traffic by
|
||||
* remembering which friend received the updated avatar already and only send
|
||||
* it if the friend has an out of date avatar.
|
||||
*
|
||||
* Clients who receive avatar send requests can reject it (by sending
|
||||
* OCTToxFileControl before any other controls), or accept it (by
|
||||
* sending OCTToxFileControlResume). The fileId of length kOCTToxHashLength bytes
|
||||
* (same length as kOCTToxFileIdLength) will contain the hash. A client can compare
|
||||
* this hash with a saved hash and send OCTToxFileControlCancel to terminate the avatar
|
||||
* transfer if it matches.
|
||||
*
|
||||
* When fileSize is set to 0 in the transfer request it means that the client has no
|
||||
* avatar.
|
||||
*/
|
||||
OCTToxFileKindAvatar,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTToxFileControl) {
|
||||
/**
|
||||
* Sent by the receiving side to accept a file send request. Also sent after a
|
||||
* OCTToxFileControlPause command to continue sending or receiving.
|
||||
*/
|
||||
OCTToxFileControlResume,
|
||||
|
||||
/**
|
||||
* Sent by clients to pause the file transfer. The initial state of a file
|
||||
* transfer is always paused on the receiving side and running on the sending
|
||||
* side. If both the sending and receiving side pause the transfer, then both
|
||||
* need to send OCTToxFileControlResume for the transfer to resume.
|
||||
*/
|
||||
OCTToxFileControlPause,
|
||||
|
||||
/**
|
||||
* Sent by the receiving side to reject a file send request before any other
|
||||
* commands are sent. Also sent by either side to terminate a file transfer.
|
||||
*/
|
||||
OCTToxFileControlCancel,
|
||||
};
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Error Codes
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Error codes for init method.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorInitCode) {
|
||||
OCTToxErrorInitCodeUnknown,
|
||||
/**
|
||||
* Was unable to allocate enough memory to store the internal structures for the Tox object.
|
||||
*/
|
||||
OCTToxErrorInitCodeMemoryError,
|
||||
|
||||
/**
|
||||
* Was unable to bind to a port. This may mean that all ports have already been bound,
|
||||
* e.g. by other Tox instances, or it may mean a permission error.
|
||||
*/
|
||||
OCTToxErrorInitCodePortAlloc,
|
||||
|
||||
/**
|
||||
* proxyType was invalid.
|
||||
*/
|
||||
OCTToxErrorInitCodeProxyBadType,
|
||||
|
||||
/**
|
||||
* proxyAddress had an invalid format or was nil (while proxyType was set).
|
||||
*/
|
||||
OCTToxErrorInitCodeProxyBadHost,
|
||||
|
||||
/**
|
||||
* proxyPort was invalid.
|
||||
*/
|
||||
OCTToxErrorInitCodeProxyBadPort,
|
||||
|
||||
/**
|
||||
* The proxy host passed could not be resolved.
|
||||
*/
|
||||
OCTToxErrorInitCodeProxyNotFound,
|
||||
|
||||
/**
|
||||
* The saved data to be loaded contained an encrypted save.
|
||||
*/
|
||||
OCTToxErrorInitCodeEncrypted,
|
||||
|
||||
/**
|
||||
* The data format was invalid. This can happen when loading data that was
|
||||
* saved by an older version of Tox, or when the data has been corrupted.
|
||||
* When loading from badly formatted data, some data may have been loaded,
|
||||
* and the rest is discarded. Passing an invalid length parameter also
|
||||
* causes this error.
|
||||
*/
|
||||
OCTToxErrorInitCodeLoadBadFormat,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for bootstrap and addTCPRelay methods.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorBootstrapCode) {
|
||||
OCTToxErrorBootstrapCodeUnknown,
|
||||
|
||||
/**
|
||||
* The host could not be resolved to an IP address, or the IP address passed was invalid.
|
||||
*/
|
||||
OCTToxErrorBootstrapCodeBadHost,
|
||||
|
||||
/**
|
||||
* The port passed was invalid. The valid port range is (1, 65535).
|
||||
*/
|
||||
OCTToxErrorBootstrapCodeBadPort,
|
||||
};
|
||||
|
||||
/**
|
||||
* Common error codes for all methods that set a piece of user-visible client information.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorSetInfoCode) {
|
||||
OCTToxErrorSetInfoCodeUnknow,
|
||||
|
||||
/**
|
||||
* Information length exceeded maximum permissible size.
|
||||
*/
|
||||
OCTToxErrorSetInfoCodeTooLong,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for addFriend method.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorFriendAdd) {
|
||||
OCTToxErrorFriendAddUnknown,
|
||||
|
||||
/**
|
||||
* The length of the friend request message exceeded kOCTToxMaxFriendRequestLength.
|
||||
*/
|
||||
OCTToxErrorFriendAddTooLong,
|
||||
|
||||
/**
|
||||
* The friend request message was empty.
|
||||
*/
|
||||
OCTToxErrorFriendAddNoMessage,
|
||||
|
||||
/**
|
||||
* The friend address belongs to the sending client.
|
||||
*/
|
||||
OCTToxErrorFriendAddOwnKey,
|
||||
|
||||
/**
|
||||
* A friend request has already been sent, or the address belongs to a friend
|
||||
* that is already on the friend list.
|
||||
*/
|
||||
OCTToxErrorFriendAddAlreadySent,
|
||||
|
||||
/**
|
||||
* The friend address checksum failed.
|
||||
*/
|
||||
OCTToxErrorFriendAddBadChecksum,
|
||||
|
||||
/**
|
||||
* The friend was already there, but the nospam value was different.
|
||||
*/
|
||||
OCTToxErrorFriendAddSetNewNospam,
|
||||
|
||||
/**
|
||||
* A memory allocation failed when trying to increase the friend list size.
|
||||
*/
|
||||
OCTToxErrorFriendAddMalloc,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for deleteFriend method.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorFriendDelete) {
|
||||
/**
|
||||
* There was no friend with the given friend number. No friends were deleted.
|
||||
*/
|
||||
OCTToxErrorFriendDeleteNotFound,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for friendNumberWithPublicKey
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorFriendByPublicKey) {
|
||||
OCTToxErrorFriendByPublicKeyUnknown,
|
||||
|
||||
/**
|
||||
* No friend with the given Public Key exists on the friend list.
|
||||
*/
|
||||
OCTToxErrorFriendByPublicKeyNotFound,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for publicKeyFromFriendNumber.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorFriendGetPublicKey) {
|
||||
/**
|
||||
* No friend with the given number exists on the friend list.
|
||||
*/
|
||||
OCTToxErrorFriendGetPublicKeyFriendNotFound,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for last online methods.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorFriendGetLastOnline) {
|
||||
/**
|
||||
* No friend with the given number exists on the friend list.
|
||||
*/
|
||||
OCTToxErrorFriendGetLastOnlineFriendNotFound,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for friend state query methods.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorFriendQuery) {
|
||||
OCTToxErrorFriendQueryUnknown,
|
||||
|
||||
/**
|
||||
* The friendNumber did not designate a valid friend.
|
||||
*/
|
||||
OCTToxErrorFriendQueryFriendNotFound,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for changing isTyping.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorSetTyping) {
|
||||
/**
|
||||
* The friend number did not designate a valid friend.
|
||||
*/
|
||||
OCTToxErrorSetTypingFriendNotFound,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for sending message.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorFriendSendMessage) {
|
||||
OCTToxErrorFriendSendMessageUnknown,
|
||||
|
||||
/**
|
||||
* The friend number did not designate a valid friend.
|
||||
*/
|
||||
OCTToxErrorFriendSendMessageFriendNotFound,
|
||||
|
||||
/**
|
||||
* This client is currently not connected to the friend.
|
||||
*/
|
||||
OCTToxErrorFriendSendMessageFriendNotConnected,
|
||||
|
||||
/**
|
||||
* An allocation error occurred while increasing the send queue size.
|
||||
*/
|
||||
OCTToxErrorFriendSendMessageAlloc,
|
||||
|
||||
/**
|
||||
* Message length exceeded kOCTToxMaxMessageLength.
|
||||
*/
|
||||
OCTToxErrorFriendSendMessageTooLong,
|
||||
|
||||
/**
|
||||
* Attempted to send a zero-length message.
|
||||
*/
|
||||
OCTToxErrorFriendSendMessageEmpty,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for sending file control.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorFileControl) {
|
||||
/**
|
||||
* The friendNumber passed did not designate a valid friend.
|
||||
*/
|
||||
OCTToxErrorFileControlFriendNotFound,
|
||||
|
||||
/**
|
||||
* This client is currently not connected to the friend.
|
||||
*/
|
||||
OCTToxErrorFileControlFriendNotConnected,
|
||||
|
||||
/**
|
||||
* No file transfer with the given file number was found for the given friend.
|
||||
*/
|
||||
OCTToxErrorFileControlNotFound,
|
||||
|
||||
/**
|
||||
* A OCTToxFileControlResume control was sent, but the file transfer is running normally.
|
||||
*/
|
||||
OCTToxErrorFileControlNotPaused,
|
||||
|
||||
/**
|
||||
* A OCTToxFileControlResume control was sent, but the file transfer was paused by the other
|
||||
* party. Only the party that paused the transfer can resume it.
|
||||
*/
|
||||
OCTToxErrorFileControlDenied,
|
||||
|
||||
/**
|
||||
* A OCTToxFileControlPause control was sent, but the file transfer was already paused.
|
||||
*/
|
||||
OCTToxErrorFileControlAlreadyPaused,
|
||||
|
||||
/**
|
||||
* Packet queue is full.
|
||||
*/
|
||||
OCTToxErrorFileControlSendq,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for file seek method.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorFileSeek) {
|
||||
/**
|
||||
* The friendNumber passed did not designate a valid friend.
|
||||
*/
|
||||
OCTToxErrorFileSeekFriendNotFound,
|
||||
|
||||
/**
|
||||
* This client is currently not connected to the friend.
|
||||
*/
|
||||
OCTToxErrorFileSeekFriendNotConnected,
|
||||
|
||||
/**
|
||||
* No file transfer with the given file number was found for the given friend.
|
||||
*/
|
||||
OCTToxErrorFileSeekNotFound,
|
||||
|
||||
/**
|
||||
* File was not in a state where it could be seeked.
|
||||
*/
|
||||
OCTToxErrorFileSeekDenied,
|
||||
|
||||
/**
|
||||
* Seek position was invalid
|
||||
*/
|
||||
OCTToxErrorFileSeekInvalidPosition,
|
||||
|
||||
/**
|
||||
* Packet queue is full.
|
||||
*/
|
||||
OCTToxErrorFileSeekSendq,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for fileGetFileId method.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorFileGet) {
|
||||
/**
|
||||
* Internal error.
|
||||
**/
|
||||
OCTToxErrorFileGetInternal,
|
||||
|
||||
/**
|
||||
* The friendNumber passed did not designate a valid friend.
|
||||
*/
|
||||
OCTToxErrorFileGetFriendNotFound,
|
||||
|
||||
/**
|
||||
* No file transfer with the given file number was found for the given friend.
|
||||
*/
|
||||
OCTToxErrorFileGetNotFound,
|
||||
|
||||
/**
|
||||
* One of the arguments to the function was NULL when it was not expected.
|
||||
*/
|
||||
OCTToxErrorFileGetNULL,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for fileSend method.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorFileSend) {
|
||||
OCTToxErrorFileSendUnknown,
|
||||
|
||||
/**
|
||||
* The friendNumber passed did not designate a valid friend.
|
||||
*/
|
||||
OCTToxErrorFileSendFriendNotFound,
|
||||
|
||||
/**
|
||||
* This client is currently not connected to the friend.
|
||||
*/
|
||||
OCTToxErrorFileSendFriendNotConnected,
|
||||
|
||||
/**
|
||||
* Filename length exceeded kOCTToxMaxFileNameLength bytes.
|
||||
*/
|
||||
OCTToxErrorFileSendNameTooLong,
|
||||
|
||||
/**
|
||||
* Too many ongoing transfers. The maximum number of concurrent file transfers
|
||||
* is 256 per friend per direction (sending and receiving).
|
||||
*/
|
||||
OCTToxErrorFileSendTooMany,
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for fileSendChunk method.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, OCTToxErrorFileSendChunk) {
|
||||
OCTToxErrorFileSendChunkUnknown,
|
||||
|
||||
/**
|
||||
* The friendNumber passed did not designate a valid friend.
|
||||
*/
|
||||
OCTToxErrorFileSendChunkFriendNotFound,
|
||||
|
||||
/**
|
||||
* This client is currently not connected to the friend.
|
||||
*/
|
||||
OCTToxErrorFileSendChunkFriendNotConnected,
|
||||
|
||||
/**
|
||||
* No file transfer with the given file number was found for the given friend.
|
||||
*/
|
||||
OCTToxErrorFileSendChunkNotFound,
|
||||
|
||||
/**
|
||||
* File transfer was found but isn't in a transferring state: (paused, done,
|
||||
* broken, etc...) (happens only when not called from the request chunk callback).
|
||||
*/
|
||||
OCTToxErrorFileSendChunkNotTransferring,
|
||||
|
||||
/**
|
||||
* Attempted to send more or less data than requested. The requested data size is
|
||||
* adjusted according to maximum transmission unit and the expected end of
|
||||
* the file. Trying to send less or more than requested will return this error.
|
||||
*/
|
||||
OCTToxErrorFileSendChunkInvalidLength,
|
||||
|
||||
/**
|
||||
* Packet queue is full.
|
||||
*/
|
||||
OCTToxErrorFileSendChunkSendq,
|
||||
|
||||
/**
|
||||
* Position parameter was wrong.
|
||||
*/
|
||||
OCTToxErrorFileSendChunkWrongPosition,
|
||||
};
|
219
local_pod_repo/objcTox/Classes/Public/Wrapper/OCTToxDelegate.h
Normal file
219
local_pod_repo/objcTox/Classes/Public/Wrapper/OCTToxDelegate.h
Normal file
@ -0,0 +1,219 @@
|
||||
// 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 "OCTToxConstants.h"
|
||||
|
||||
@class OCTTox;
|
||||
|
||||
/**
|
||||
* All delegate methods will be called on main thread.
|
||||
*/
|
||||
@protocol OCTToxDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
/**
|
||||
* User connection status changed.
|
||||
*
|
||||
* @param connectionStatus New connection status of the user.
|
||||
*/
|
||||
- (void)tox:(OCTTox *)tox connectionStatus:(OCTToxConnectionStatus)connectionStatus;
|
||||
|
||||
/**
|
||||
* Received friend request from a new friend.
|
||||
*
|
||||
* @param message Message sent with request.
|
||||
* @param publicKey New friend public key.
|
||||
*/
|
||||
- (void)tox:(OCTTox *)tox friendRequestWithMessage:(NSString *)message publicKey:(NSString *)publicKey;
|
||||
|
||||
/**
|
||||
* Message received from a friend.
|
||||
*
|
||||
* @param message Received message.
|
||||
* @param type Type of the message.
|
||||
* @param friendNumber Friend number of appropriate friend.
|
||||
* @param msgv3HashHex messageV3 Hash as Hexstring or nil.
|
||||
* @param sendTimestamp unixtimestamp. if msgv3HashHex is nil then timestamp is ignored and current time is used.
|
||||
*/
|
||||
- (void)tox:(OCTTox *)tox friendMessage:(NSString *)message
|
||||
type:(OCTToxMessageType)type
|
||||
friendNumber:(OCTToxFriendNumber)friendNumber
|
||||
msgv3HashHex:(NSString *)msgv3HashHex
|
||||
sendTimestamp:(uint32_t)sendTimestamp;
|
||||
|
||||
/**
|
||||
* Send msgV3 high level ACK message.
|
||||
*
|
||||
* @param message Message text.
|
||||
* @param friendNumber Friend number of appropriate friend.
|
||||
* @param msgv3HashHex messageV3 Hash as Hexstring.
|
||||
* @param sendTimestamp unixtimestamp.
|
||||
*/
|
||||
- (void)tox:(OCTTox *)tox sendFriendHighlevelACK:(NSString *)message
|
||||
friendNumber:(OCTToxFriendNumber)friendNumber
|
||||
msgv3HashHex:(NSString *)msgv3HashHex
|
||||
sendTimestamp:(uint32_t)sendTimestamp;
|
||||
/**
|
||||
* Friend's name was updated.
|
||||
*
|
||||
* @param name Updated name.
|
||||
* @param friendNumber Friend number of appropriate friend.
|
||||
*/
|
||||
- (void)tox:(OCTTox *)tox friendNameUpdate:(NSString *)name friendNumber:(OCTToxFriendNumber)friendNumber;
|
||||
|
||||
/**
|
||||
* Friend's Push Token was updated.
|
||||
*
|
||||
* @param pushToken Updated Push Token.
|
||||
* @param friendNumber Friend number of appropriate friend.
|
||||
*/
|
||||
- (void)tox:(OCTTox *)tox friendPushTokenUpdate:(NSString *)pushToken friendNumber:(OCTToxFriendNumber)friendNumber;
|
||||
|
||||
/**
|
||||
* Friend's status message was updated.
|
||||
*
|
||||
* @param statusMessage Updated status message.
|
||||
* @param friendNumber Friend number of appropriate friend.
|
||||
*/
|
||||
- (void)tox:(OCTTox *)tox friendStatusMessageUpdate:(NSString *)statusMessage friendNumber:(OCTToxFriendNumber)friendNumber;
|
||||
|
||||
/**
|
||||
* Friend's status was updated.
|
||||
*
|
||||
* @param status Updated status.
|
||||
* @param friendNumber Friend number of appropriate friend.
|
||||
*/
|
||||
- (void)tox:(OCTTox *)tox friendStatusUpdate:(OCTToxUserStatus)status friendNumber:(OCTToxFriendNumber)friendNumber;
|
||||
|
||||
/**
|
||||
* Friend's isTyping was updated
|
||||
*
|
||||
* @param isTyping Updated typing status.
|
||||
* @param friendNumber Friend number of appropriate friend.
|
||||
*/
|
||||
- (void)tox:(OCTTox *)tox friendIsTypingUpdate:(BOOL)isTyping friendNumber:(OCTToxFriendNumber)friendNumber;
|
||||
|
||||
/**
|
||||
* Friend's Msgv3Capability needs to be updated
|
||||
*
|
||||
* @param msgv3Capability Updated msgV3 status.
|
||||
* @param friendNumber Friend number of appropriate friend.
|
||||
*/
|
||||
- (void)tox:(OCTTox *)tox friendSetMsgv3Capability:(BOOL)msgv3Capability friendNumber:(OCTToxFriendNumber)friendNumber;
|
||||
|
||||
/**
|
||||
* Message that was previously sent by us has been delivered to a friend.
|
||||
*
|
||||
* @param messageId Id of message. You could get in in sendMessage method.
|
||||
* @param friendNumber Friend number of appropriate friend.
|
||||
*/
|
||||
- (void)tox:(OCTTox *)tox messageDelivered:(OCTToxMessageId)messageId friendNumber:(OCTToxFriendNumber)friendNumber;
|
||||
|
||||
/**
|
||||
* Message that was previously sent by us has been delivered to a friend.
|
||||
*
|
||||
* @param message Received message. UNUSED for now.
|
||||
* @param friendNumber Friend number of appropriate friend.
|
||||
* @param msgv3HashHex messageV3 Hash as Hexstring.
|
||||
* @param sendTimestamp unixtimestamp.
|
||||
*/
|
||||
- (void)tox:(OCTTox *)tox friendHighLevelACK:(NSString *)message
|
||||
friendNumber:(OCTToxFriendNumber)friendNumber
|
||||
msgv3HashHex:(NSString *)msgv3HashHex
|
||||
sendTimestamp:(uint32_t)sendTimestamp;
|
||||
|
||||
/**
|
||||
* Friend's connection status changed.
|
||||
*
|
||||
* @param status Updated status.
|
||||
* @param friendNumber Friend number of appropriate friend.
|
||||
*/
|
||||
- (void)tox:(OCTTox *)tox friendConnectionStatusChanged:(OCTToxConnectionStatus)status friendNumber:(OCTToxFriendNumber)friendNumber;
|
||||
|
||||
/**
|
||||
* This event is triggered when a file control command is received from a friend.
|
||||
*
|
||||
* When receiving OCTToxFileControlCancel, the client should release the
|
||||
* resources associated with the file number and consider the transfer failed.
|
||||
*
|
||||
* @param control The control command to send.
|
||||
* @param friendNumber The friend number of the friend the file is being transferred to or received from.
|
||||
* @param fileNumber The friend-specific identifier for the file transfer.
|
||||
*/
|
||||
- (void) tox:(OCTTox *)tox fileReceiveControl:(OCTToxFileControl)control
|
||||
friendNumber:(OCTToxFriendNumber)friendNumber
|
||||
fileNumber:(OCTToxFileNumber)fileNumber;
|
||||
|
||||
/**
|
||||
* If the length parameter is 0, the file transfer is finished, and the client's
|
||||
* resources associated with the file number should be released. After a call
|
||||
* with zero length, the file number can be reused for future file transfers.
|
||||
*
|
||||
* If the requested position is not equal to the client's idea of the current
|
||||
* file or stream position, it will need to seek. In case of read-once streams,
|
||||
* the client should keep the last read chunk so that a seek back can be
|
||||
* supported. A seek-back only ever needs to read from the last requested chunk.
|
||||
* This happens when a chunk was requested, but the send failed. A seek-back
|
||||
* request can occur an arbitrary number of times for any given chunk.
|
||||
*
|
||||
* In response to receiving this callback, the client should call the method
|
||||
* `fileSendChunk` with the requested chunk. If the number of bytes sent
|
||||
* through that method is zero, the file transfer is assumed complete. A
|
||||
* client must send the full length of data requested with this callback.
|
||||
*
|
||||
* @param friendNumber The friend number of the receiving friend for this file.
|
||||
* @param fileNumber The file transfer identifier returned by fileSend.
|
||||
* @param position The file or stream position from which to continue reading.
|
||||
* @param length The number of bytes requested for the current chunk.
|
||||
*/
|
||||
- (void) tox:(OCTTox *)tox fileChunkRequestForFileNumber:(OCTToxFileNumber)fileNumber
|
||||
friendNumber:(OCTToxFriendNumber)friendNumber
|
||||
position:(OCTToxFileSize)position
|
||||
length:(size_t)length;
|
||||
|
||||
/**
|
||||
* The client should acquire resources to be associated with the file transfer.
|
||||
* Incoming file transfers start in the PAUSED state. After this callback
|
||||
* returns, a transfer can be rejected by sending a OCTToxFileControlCancel
|
||||
* control command before any other control commands. It can be accepted by
|
||||
* sending OCTToxFileControlResume.
|
||||
*
|
||||
* @param fileNumber The friend-specific file number the data received is associated with.
|
||||
* @param friendNumber The friend number of the friend who is sending the file transfer request.
|
||||
* @param kind The meaning of the file to be sent.
|
||||
* @param fileSize Size in bytes of the file about to be received from the client, kOCTToxFileSizeUnknown if unknown or streaming.
|
||||
* @param fileName The name of the file.
|
||||
*/
|
||||
- (void) tox:(OCTTox *)tox fileReceiveForFileNumber:(OCTToxFileNumber)fileNumber
|
||||
friendNumber:(OCTToxFriendNumber)friendNumber
|
||||
kind:(OCTToxFileKind)kind
|
||||
fileSize:(OCTToxFileSize)fileSize
|
||||
fileName:(NSString *)fileName;
|
||||
|
||||
/**
|
||||
* This method is first called when a file transfer request is received, and
|
||||
* subsequently when a chunk of file data for an accepted request was received.
|
||||
*
|
||||
* When chunk is nil, the transfer is finished and the client should release the
|
||||
* resources it acquired for the transfer. After a call with chunk = nil, the
|
||||
* file number can be reused for new file transfers.
|
||||
*
|
||||
* If position is equal to fileSize (received in the fileReceive callback)
|
||||
* when the transfer finishes, the file was received completely. Otherwise, if
|
||||
* fileSize was kOCTToxFileSizeUnknown, streaming ended successfully when chunk is nil.
|
||||
*
|
||||
* @param chunk A data containing the received chunk.
|
||||
* @param fileNumber The friend-specific file number the data received is associated with.
|
||||
* @param friendNumber The friend number of the friend who is sending the file.
|
||||
* @param position The file position of the first byte in data.
|
||||
*/
|
||||
- (void) tox:(OCTTox *)tox fileReceiveChunk:(NSData *)chunk
|
||||
fileNumber:(OCTToxFileNumber)fileNumber
|
||||
friendNumber:(OCTToxFriendNumber)friendNumber
|
||||
position:(OCTToxFileSize)position;
|
||||
|
||||
@end
|
@ -0,0 +1,93 @@
|
||||
// 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>
|
||||
|
||||
/**
|
||||
* This class is used for encryption/decryption of save data.
|
||||
*
|
||||
* You can use class methods or create instance and use it's methods.
|
||||
* Note that instance encryption/decryption methods are much faster because
|
||||
* instance stores generated encryption key.
|
||||
*/
|
||||
@interface OCTToxEncryptSave : NSObject
|
||||
|
||||
/**
|
||||
* Determines whether or not the given data is encrypted (by checking the magic number).
|
||||
*
|
||||
* @param data Data to check.
|
||||
*
|
||||
* @return YES if data is encrypted, NO otherwise.
|
||||
*/
|
||||
+ (BOOL)isDataEncrypted:(nonnull NSData *)data;
|
||||
|
||||
/**
|
||||
* Encrypts the given data with the given passphrase.
|
||||
*
|
||||
* @param data Data to encrypt.
|
||||
* @param passphrase Passphrase used to encrypt the data.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxEncryptSaveEncryptionError for all error codes.
|
||||
*
|
||||
* @return Encrypted data on success, nil on failure.
|
||||
*/
|
||||
+ (nullable NSData *)encryptData:(nonnull NSData *)data
|
||||
withPassphrase:(nonnull NSString *)passphrase
|
||||
error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* Decrypts the given data with the given passphrase.
|
||||
*
|
||||
* @param data Data to decrypt.
|
||||
* @param passphrase Passphrase used to decrypt the data.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxEncryptSaveDecryptionError for all error codes.
|
||||
*
|
||||
* @return Decrypted data on success, nil on failure.
|
||||
*/
|
||||
+ (nullable NSData *)decryptData:(nonnull NSData *)data
|
||||
withPassphrase:(nonnull NSString *)passphrase
|
||||
error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* Creates new instance of OCTToxEncryptSave object with given passphrase. This instance can be used
|
||||
* to encrypt and decrypt given data.
|
||||
* Encryption key is generated and stored in this method. Due to that encrypting/decrypting data
|
||||
* using instance instead of class methods is much faster, as key derivation is very expensive compared
|
||||
* to the actual encryption.
|
||||
*
|
||||
* @param passphrase Passphrase used to encrypt/decrypt the data.
|
||||
* @param toxData If you have toxData that you would like to decrypt, you have to pass it here. Salt will be extracted from data and used for key generation.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxEncryptSaveKeyDerivationError for all error codes.
|
||||
*
|
||||
* @return Created instance or nil in case of error.
|
||||
*/
|
||||
- (nullable instancetype)initWithPassphrase:(nonnull NSString *)passphrase
|
||||
toxData:(nullable NSData *)toxData
|
||||
error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* Encrypts the given data.
|
||||
*
|
||||
* @param data Data to encrypt.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxEncryptSaveEncryptionError for all error codes.
|
||||
*
|
||||
* @return Encrypted data on success, nil on failure.
|
||||
*/
|
||||
- (nullable NSData *)encryptData:(nonnull NSData *)data error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
/**
|
||||
* Decrypts the given data.
|
||||
*
|
||||
* @param data Data to decrypt.
|
||||
* @param error If an error occurs, this pointer is set to an actual error object containing the error information.
|
||||
* See OCTToxEncryptSaveDecryptionError for all error codes.
|
||||
*
|
||||
* @return Decrypted data on success, nil on failure.
|
||||
*/
|
||||
- (nullable NSData *)decryptData:(nonnull NSData *)data error:(NSError *__nullable *__nullable)error;
|
||||
|
||||
@end
|
@ -0,0 +1,41 @@
|
||||
// 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/.
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTToxEncryptSaveKeyDerivationError) {
|
||||
OCTToxEncryptSaveKeyDerivationErrorNone,
|
||||
OCTToxEncryptSaveKeyDerivationErrorFailed,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTToxEncryptSaveEncryptionError) {
|
||||
OCTToxEncryptSaveEncryptionErrorNone,
|
||||
|
||||
/**
|
||||
* Some input data was empty.
|
||||
*/
|
||||
OCTToxEncryptSaveEncryptionErrorNull,
|
||||
|
||||
/**
|
||||
* Encryption failed.
|
||||
*/
|
||||
OCTToxEncryptSaveEncryptionErrorFailed,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, OCTToxEncryptSaveDecryptionError) {
|
||||
OCTToxEncryptSaveDecryptionErrorNone,
|
||||
|
||||
/**
|
||||
* Some input data was empty.
|
||||
*/
|
||||
OCTToxEncryptSaveDecryptionErrorNull,
|
||||
|
||||
/**
|
||||
* The input data is missing the magic number (i.e. wasn't created by this module, or is corrupted).
|
||||
*/
|
||||
OCTToxEncryptSaveDecryptionErrorBadFormat,
|
||||
|
||||
/**
|
||||
* The encrypted byte array could not be decrypted. Either the data was corrupt or the password/key was incorrect.
|
||||
*/
|
||||
OCTToxEncryptSaveDecryptionErrorFailed,
|
||||
};
|
103
local_pod_repo/objcTox/Classes/Public/Wrapper/OCTToxOptions.h
Normal file
103
local_pod_repo/objcTox/Classes/Public/Wrapper/OCTToxOptions.h
Normal file
@ -0,0 +1,103 @@
|
||||
// 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 "OCTToxConstants.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* After creation OCTToxOptions will have predefined default values.
|
||||
*/
|
||||
@interface OCTToxOptions : NSObject <NSCopying>
|
||||
|
||||
/**
|
||||
* The type of socket to create.
|
||||
*
|
||||
* If this is set to false, an IPv4 socket is created, which subsequently
|
||||
* only allows IPv4 communication.
|
||||
* If it is set to true, an IPv6 socket is created, allowing both IPv4 and
|
||||
* IPv6 communication.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL ipv6Enabled;
|
||||
|
||||
/**
|
||||
* Enable the use of UDP communication when available.
|
||||
*
|
||||
* Setting this to false will force Tox to use TCP only. Communications will
|
||||
* need to be relayed through a TCP relay node, potentially slowing them down.
|
||||
* Disabling UDP support is necessary when using anonymous proxies or Tor.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL udpEnabled;
|
||||
|
||||
/**
|
||||
* Enable local network peer discovery.
|
||||
*
|
||||
* Disabling this will cause Tox to not look for peers on the local network.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL localDiscoveryEnabled;
|
||||
|
||||
/**
|
||||
* Pass communications through a proxy.
|
||||
*/
|
||||
@property (nonatomic, assign) OCTToxProxyType proxyType;
|
||||
|
||||
/**
|
||||
* The IP address or DNS name of the proxy to be used.
|
||||
*
|
||||
* If used, this must be non-NULL and be a valid DNS name. The name must not
|
||||
* exceed 255 characters.
|
||||
*
|
||||
* This member is ignored (it can be nil) if proxyType is OCTToxProxyTypeNone.
|
||||
*/
|
||||
@property (nonatomic, copy, nullable) NSString *proxyHost;
|
||||
|
||||
/**
|
||||
* The port to use to connect to the proxy server.
|
||||
*
|
||||
* Ports must be in the range (1, 65535). The value is ignored if
|
||||
* proxyType is OCTToxProxyTypeNone.
|
||||
*/
|
||||
@property (nonatomic, assign) uint16_t proxyPort;
|
||||
|
||||
/**
|
||||
* The start port of the inclusive port range to attempt to use.
|
||||
*
|
||||
* If both start_port and end_port are 0, the default port range will be
|
||||
* used: [33445, 33545].
|
||||
*
|
||||
* If either start_port or end_port is 0 while the other is non-zero, the
|
||||
* non-zero port will be the only port in the range.
|
||||
*
|
||||
* Having start_port > end_port will yield the same behavior as if start_port
|
||||
* and end_port were swapped.
|
||||
*/
|
||||
@property (nonatomic, assign) uint16_t startPort;
|
||||
|
||||
/**
|
||||
* The end port of the inclusive port range to attempt to use.
|
||||
*/
|
||||
@property (nonatomic, assign) uint16_t endPort;
|
||||
|
||||
/**
|
||||
* The port to use for the TCP server (relay). If 0, the TCP server is
|
||||
* disabled.
|
||||
*
|
||||
* Enabling it is not required for Tox to function properly.
|
||||
*
|
||||
* When enabled, your Tox instance can act as a TCP relay for other Tox
|
||||
* instance. This leads to increased traffic, thus when writing a client
|
||||
* it is recommended to enable TCP server only if the user has an option
|
||||
* to disable it.
|
||||
*/
|
||||
@property (nonatomic, assign) uint16_t tcpPort;
|
||||
|
||||
/**
|
||||
* Enables or disables UDP hole-punching in toxcore. (Default: enabled).
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL holePunchingEnabled;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
Reference in New Issue
Block a user