Initial commit

This commit is contained in:
Tha_14
2024-02-22 21:43:11 +02:00
commit 1b96a031d2
1108 changed files with 157706 additions and 0 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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