Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions NextcloudTalk/Calls/CallKitManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ - (void)getCallInfoForCall:(CallKitCall *)call
}

TalkAccount *account = [[NCDatabaseManager sharedInstance] talkAccountForAccountId:call.accountId];
[[NCAPIController sharedInstance] getRoomForAccount:account withToken:call.token completionBlock:^(NSDictionary *roomDict, NSError *error) {
[[NCAPIController sharedInstance] getRoomForAccount:account withToken:call.token completionBlock:^(NSDictionary *roomDict, OcsError *error) {
if (!error) {
NCRoom *room = [NCRoom roomWithDictionary:roomDict andAccountId:call.accountId];
[self updateCall:call withDisplayName:room.displayName];
Expand Down Expand Up @@ -415,7 +415,7 @@ - (void)checkCallStateWithPeersForCall:(CallKitCall *)call
__weak CallKitManager *weakSelf = self;

TalkAccount *account = [[NCDatabaseManager sharedInstance] talkAccountForAccountId:call.accountId];
[[NCAPIController sharedInstance] getPeersForCallInRoom:call.token forAccount:account completionBlock:^(NSArray<NSDictionary<NSString *, id> *> * _Nullable peers, NSError * _Nullable error, NSInteger statusCode) {
[[NCAPIController sharedInstance] getPeersForCallInRoom:call.token forAccount:account completionBlock:^(NSArray<NSDictionary<NSString *, id> *> * _Nullable peers, OcsError * _Nullable error, NSInteger statusCode) {
// Make sure call is still ringing at this point to avoid a race-condition between answering the call on this device and the API callback
if (!call.isRinging) {
return;
Expand Down
18 changes: 9 additions & 9 deletions NextcloudTalk/Calls/NCCallController.m
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ - (void)joinCall
{
[NCLog log:[NSString stringWithFormat:@"Join call in NCCallController for token %@", self.room.token]];

_joinCallTask = [[NCAPIController sharedInstance] joinCallInRoom:_room.token withCallFlags:[self joinCallFlags] joinSilently:_silentCall joinSilentlyFor:_silentFor withRecordingConsent:_recordingConsent forAccount:_account completionBlock:^(NSError * _Nullable error , NSInteger statusCode) {
_joinCallTask = [[NCAPIController sharedInstance] joinCallInRoom:_room.token withCallFlags:[self joinCallFlags] joinSilently:_silentCall joinSilentlyFor:_silentFor withRecordingConsent:_recordingConsent forAccount:_account completionBlock:^(OcsError * _Nullable error , NSInteger statusCode) {
[[WebRTCCommon shared] dispatch:^{
if (!error) {
[NCLog log:[NSString stringWithFormat:@"Did join call in NCCallController for token %@", self.room.token]];
Expand All @@ -199,7 +199,7 @@ - (void)joinCall
self->_joinedCallOnce = YES;
self->_joinCallAttempts = 0;
} else {
if (error.code == NSURLErrorCancelled) {
if ([error underlyingError].code == NSURLErrorCancelled) {
self->_joinCallAttempts = 0;
return;
}
Expand Down Expand Up @@ -259,7 +259,7 @@ - (void)shouldRejoinCall
{
[self createLocalMedia];

_joinCallTask = [[NCAPIController sharedInstance] joinCallInRoom:_room.token withCallFlags:[self joinCallFlags] joinSilently:_silentCall joinSilentlyFor:_silentFor withRecordingConsent:_recordingConsent forAccount:_account completionBlock:^(NSError * _Nullable error, NSInteger statusCode) {
_joinCallTask = [[NCAPIController sharedInstance] joinCallInRoom:_room.token withCallFlags:[self joinCallFlags] joinSilently:_silentCall joinSilentlyFor:_silentFor withRecordingConsent:_recordingConsent forAccount:_account completionBlock:^(OcsError * _Nullable error, NSInteger statusCode) {
[[WebRTCCommon shared] dispatch:^{
if (!error) {
[self.delegate callControllerDidJoinCall:self];
Expand Down Expand Up @@ -307,7 +307,7 @@ - (void)willSwitchToCall:(NSString *)token

[self stopCallController];

[self leaveCallInServerForAll:NO withCompletionBlock:^(NSError *error) {
[self leaveCallInServerForAll:NO withCompletionBlock:^(OcsError *error) {
if (error) {
NSLog(@"Could not leave call. Error: %@", error.description);
}
Expand Down Expand Up @@ -344,7 +344,7 @@ - (void)forceReconnect

- (void)rejoinCallUsingInternalSignaling
{
[[NCAPIController sharedInstance] leaveCallInRoom:_room.token forAllParticipants:NO forAccount:[[NCDatabaseManager sharedInstance] activeAccount] completionBlock:^(NSError * _Nullable error) {
[[NCAPIController sharedInstance] leaveCallInRoom:_room.token forAllParticipants:NO forAccount:[[NCDatabaseManager sharedInstance] activeAccount] completionBlock:^(OcsError * _Nullable error) {
if (!error) {
self->_shouldRejoinCallUsingInternalSignaling = YES;
}
Expand Down Expand Up @@ -382,10 +382,10 @@ - (void)stopCallController
_joinCallTask = nil;
}

- (void)leaveCallInServerForAll:(BOOL)allParticipants withCompletionBlock:(void (^)(NSError *error))block
- (void)leaveCallInServerForAll:(BOOL)allParticipants withCompletionBlock:(void (^)(OcsError *error))block
{
if (_userInCall) {
[[NCAPIController sharedInstance] leaveCallInRoom:_room.token forAllParticipants:allParticipants forAccount:[[NCDatabaseManager sharedInstance] activeAccount] completionBlock:^(NSError * _Nullable error) {
[[NCAPIController sharedInstance] leaveCallInRoom:_room.token forAllParticipants:allParticipants forAccount:[[NCDatabaseManager sharedInstance] activeAccount] completionBlock:^(OcsError * _Nullable error) {
block(error);
}];
} else {
Expand All @@ -397,7 +397,7 @@ - (void)leaveCallForAll:(BOOL)allParticipants
{
[self stopCallController];

[self leaveCallInServerForAll:allParticipants withCompletionBlock:^(NSError *error) {
[self leaveCallInServerForAll:allParticipants withCompletionBlock:^(OcsError *error) {
if (error) {
NSLog(@"Could not leave call. Error: %@", error.description);
}
Expand Down Expand Up @@ -812,7 +812,7 @@ - (void)checkMicAudioLevel

- (void)getPeersForCall
{
_getPeersForCallTask = [[NCAPIController sharedInstance] getPeersForCallInRoom:_room.token forAccount:_account completionBlock:^(NSArray<NSDictionary<NSString *,id> *> * _Nullable peers, NSError *error, NSInteger statusCode) {
_getPeersForCallTask = [[NCAPIController sharedInstance] getPeersForCallInRoom:_room.token forAccount:_account completionBlock:^(NSArray<NSDictionary<NSString *,id> *> * _Nullable peers, OcsError *error, NSInteger statusCode) {
if (error) {
return;
}
Expand Down
7 changes: 4 additions & 3 deletions NextcloudTalk/Chat/NCChatController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

#import "NCChatMessage.h"

typedef void (^UpdateHistoryInBackgroundCompletionBlock)(NSError *error);
@class OcsError;
@class NCRoom;

typedef void (^UpdateHistoryInBackgroundCompletionBlock)(OcsError *error);
typedef void (^GetMessagesContextCompletionBlock)(NSArray<NCChatMessage *> * _Nullable messages);
typedef void (^GetSingleMessageCompletionBlock)(NCChatMessage* _Nullable message);

@class NCRoom;

extern NSString * const NCChatControllerDidReceiveInitialChatHistoryNotification;
extern NSString * const NCChatControllerDidReceiveInitialChatHistoryOfflineNotification;;
extern NSString * const NCChatControllerDidReceiveChatHistoryNotification;
Expand Down
20 changes: 10 additions & 10 deletions NextcloudTalk/Chat/NCChatController.m
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ - (void)updateHistoryInBackgroundWithCompletionBlock:(UpdateHistoryInBackgroundC
[self->_pullMessagesTask cancel];
}];

_pullMessagesTask = [[NCAPIController sharedInstance] receiveChatMessagesOfRoom:_room.token fromLastMessageId:lastChatBlock.newestMessageId inThread:_threadId history:NO includeLastMessage:NO timeout:NO limit:NCAPIController.shared.kReceivedChatMessagesLimit lastCommonReadMessage:_room.lastCommonReadMessage setReadMarker:NO markNotificationsAsRead:NO forAccount:_account completionBlock:^(NSArray *messages, NSInteger lastKnownMessage, NSInteger lastCommonReadMessage, NSError *error, NSInteger statusCode) {
_pullMessagesTask = [[NCAPIController sharedInstance] receiveChatMessagesOfRoom:_room.token fromLastMessageId:lastChatBlock.newestMessageId inThread:_threadId history:NO includeLastMessage:NO timeout:NO limit:NCAPIController.shared.kReceivedChatMessagesLimit lastCommonReadMessage:_room.lastCommonReadMessage setReadMarker:NO markNotificationsAsRead:NO forAccount:_account completionBlock:^(NSArray *messages, NSInteger lastKnownMessage, NSInteger lastCommonReadMessage, OcsError *error, NSInteger statusCode) {
if (expired) {
if (block) {
block(error);
Expand Down Expand Up @@ -632,7 +632,7 @@ - (void)getInitialChatHistory
lastReadMessageId = _room.lastReadMessage;
}

[self fetchHistoryUntilVisibleFromMessageId:lastReadMessageId forInitialChatHistory:YES isFirstIteration:YES completion:^(NSArray *messages, NSInteger lastCommonReadMessage, NSError *error, NSInteger statusCode) {
[self fetchHistoryUntilVisibleFromMessageId:lastReadMessageId forInitialChatHistory:YES isFirstIteration:YES completion:^(NSArray *messages, NSInteger lastCommonReadMessage, OcsError *error, NSInteger statusCode) {
if (error) {
if ([self isChatBeingBlocked:statusCode]) {
[self notifyChatIsBlocked];
Expand All @@ -658,7 +658,7 @@ - (void)getHistoryBatchFromMessagesId:(NSInteger)messageId
NSMutableDictionary *userInfo = [NSMutableDictionary new];
[userInfo setObject:_room.token forKey:@"room"];

[self fetchHistoryUntilVisibleFromMessageId:messageId forInitialChatHistory:NO isFirstIteration:YES completion:^(NSArray *messages, NSInteger lastCommonReadMessage, NSError *error, NSInteger statusCode) {
[self fetchHistoryUntilVisibleFromMessageId:messageId forInitialChatHistory:NO isFirstIteration:YES completion:^(NSArray *messages, NSInteger lastCommonReadMessage, OcsError *error, NSInteger statusCode) {
if (statusCode == 304) {
[self updateHistoryFlagInFirstBlock];
}
Expand All @@ -682,7 +682,7 @@ - (void)getHistoryBatchFromMessagesId:(NSInteger)messageId
}


- (void)fetchHistoryUntilVisibleFromMessageId:(NSInteger)messageId forInitialChatHistory:(BOOL)forInitialChatHistory isFirstIteration:(BOOL)isFirstIteration completion:(void (^)(NSArray *messages, NSInteger lastCommonReadMessage, NSError *error, NSInteger statusCode))completion
- (void)fetchHistoryUntilVisibleFromMessageId:(NSInteger)messageId forInitialChatHistory:(BOOL)forInitialChatHistory isFirstIteration:(BOOL)isFirstIteration completion:(void (^)(NSArray *messages, NSInteger lastCommonReadMessage, OcsError *error, NSInteger statusCode))completion
{
NCChatBlock *lastChatBlock = [self chatBlocksForRoomOrThread].lastObject;

Expand Down Expand Up @@ -740,7 +740,7 @@ - (void)fetchHistoryUntilVisibleFromMessageId:(NSInteger)messageId forInitialCha
completionBlock:^(NSArray *messages,
NSInteger lastKnownMessage,
NSInteger lastCommonReadMessage,
NSError *error,
OcsError *error,
NSInteger statusCode) {
if (self->_stopChatMessagesPoll) {
return;
Expand Down Expand Up @@ -847,7 +847,7 @@ - (void)startReceivingChatMessagesFromMessagesId:(NSInteger)messageId withTimeou
{
_stopChatMessagesPoll = NO;
[_pullMessagesTask cancel];
_pullMessagesTask = [[NCAPIController sharedInstance] receiveChatMessagesOfRoom:_room.token fromLastMessageId:messageId inThread:_threadId history:NO includeLastMessage:NO timeout:timeout limit:NCAPIController.shared.kReceivedChatMessagesLimit lastCommonReadMessage:_room.lastCommonReadMessage setReadMarker:YES markNotificationsAsRead:YES forAccount:_account completionBlock:^(NSArray *messages, NSInteger lastKnownMessage, NSInteger lastCommonReadMessage, NSError *error, NSInteger statusCode) {
_pullMessagesTask = [[NCAPIController sharedInstance] receiveChatMessagesOfRoom:_room.token fromLastMessageId:messageId inThread:_threadId history:NO includeLastMessage:NO timeout:timeout limit:NCAPIController.shared.kReceivedChatMessagesLimit lastCommonReadMessage:_room.lastCommonReadMessage setReadMarker:YES markNotificationsAsRead:YES forAccount:_account completionBlock:^(NSArray *messages, NSInteger lastKnownMessage, NSInteger lastCommonReadMessage, OcsError *error, NSInteger statusCode) {
if (self->_stopChatMessagesPoll) {
return;
}
Expand Down Expand Up @@ -899,7 +899,7 @@ - (void)startReceivingChatMessagesFromMessagesId:(NSInteger)messageId withTimeou

[self checkLastCommonReadMessage:lastCommonReadMessage];

if (error.code != -999) {
if ([error underlyingError].code != NSURLErrorCancelled) {
NCChatBlock *lastChatBlock = [self chatBlocksForRoomOrThread].lastObject;
[self startReceivingChatMessagesFromMessagesId:lastChatBlock.newestMessageId withTimeout:YES];
}
Expand Down Expand Up @@ -938,7 +938,7 @@ - (void)sendChatMessage:(NSString *)message replyTo:(NSInteger)replyTo reference
}];
}

[[NCAPIController sharedInstance] sendChatMessage:message toRoom:_room.token threadTitle:nil replyTo:replyTo referenceId:referenceId silently:silently forAccount:_account completionBlock:^(NSError *error) {
[[NCAPIController sharedInstance] sendChatMessage:message toRoom:_room.token threadTitle:nil replyTo:replyTo referenceId:referenceId silently:silently forAccount:_account completionBlock:^(OcsError *error) {
if (referenceId) {
[userInfo setObject:referenceId forKey:@"referenceId"];
}
Expand Down Expand Up @@ -1094,7 +1094,7 @@ - (BOOL)hasHistoryFromMessageId:(NSInteger)messageId

- (void)getMessageContextForMessageId:(NSInteger)messageId withLimit:(NSInteger)limit withCompletionBlock:(GetMessagesContextCompletionBlock)block
{
[[NCAPIController sharedInstance] getMessageContextInRoom:self.room.token forMessageId:messageId inThread:_threadId withLimit:limit forAccount:self.account completionBlock:^(NSArray<NCChatMessage *> *messages, NSError *error) {
[[NCAPIController sharedInstance] getMessageContextInRoom:self.room.token forMessageId:messageId inThread:_threadId withLimit:limit forAccount:self.account completionBlock:^(NSArray<NCChatMessage *> *messages, OcsError *error) {
if (error) {
if (block) {
block(nil);
Expand Down Expand Up @@ -1133,7 +1133,7 @@ - (void)getSingleMessageWithMessageId:(NSInteger)messageId withCompletionBlock:(
return;
}

[[NCAPIController sharedInstance] receiveChatMessagesOfRoom:_room.token fromLastMessageId:messageId inThread:0 history:YES includeLastMessage:YES timeout:NO limit:1 lastCommonReadMessage:0 setReadMarker:NO markNotificationsAsRead:NO forAccount:_account completionBlock:^(NSArray *messages, NSInteger lastKnownMessage, NSInteger lastCommonReadMessage, NSError *error, NSInteger statusCode) {
[[NCAPIController sharedInstance] receiveChatMessagesOfRoom:_room.token fromLastMessageId:messageId inThread:0 history:YES includeLastMessage:YES timeout:NO limit:1 lastCommonReadMessage:0 setReadMarker:NO markNotificationsAsRead:NO forAccount:_account completionBlock:^(NSArray *messages, NSInteger lastKnownMessage, NSInteger lastCommonReadMessage, OcsError *error, NSInteger statusCode) {
if (error) {
NSLog(@"Could not get single message from server. Error: %@", error.description);
block(nil);
Expand Down
2 changes: 1 addition & 1 deletion NextcloudTalk/Chat/NCChatMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ - (void)getReferenceDataWithCompletionBlock:(GetReferenceDataCompletionBlock)blo
} else {
TalkAccount *account = [[NCDatabaseManager sharedInstance] talkAccountForAccountId:_accountId];

[[NCAPIController sharedInstance] getReferenceForUrlString:_urlDetected forAccount:account completionBlock:^(NSDictionary *references, NSError *error) {
[[NCAPIController sharedInstance] getReferenceForUrlString:_urlDetected forAccount:account completionBlock:^(NSDictionary *references, OcsError *error) {
if (block) {
block(self, references, self->_urlDetected);
}
Expand Down
6 changes: 3 additions & 3 deletions NextcloudTalk/Contacts/AddParticipantsTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ - (void)removeAddingParticipantsView
- (void)getPossibleParticipants
{
TalkAccount *activeAccount = [[NCDatabaseManager sharedInstance] activeAccount];
[[NCAPIController sharedInstance] getContactsForAccount:activeAccount forRoom:_room.token forGroupRoom:YES withSearchParam:nil completionBlock:^(NSArray<NCUser *> * _Nullable contactList, NSError *error) {
[[NCAPIController sharedInstance] getContactsForAccount:activeAccount forRoom:_room.token forGroupRoom:YES withSearchParam:nil completionBlock:^(NSArray<NCUser *> * _Nullable contactList, OcsError *error) {
if (!error) {
NSMutableArray *storedContacts = [NCContact contactsForAccountId:activeAccount.accountId contains:nil];
NSMutableArray *combinedContactList = [NCUser combineUsersArray:storedContacts withUsersArray:contactList];
Expand All @@ -335,15 +335,15 @@ - (void)searchForParticipantsWithString:(NSString *)searchString
{
[_searchParticipantsTask cancel];
TalkAccount *activeAccount = [[NCDatabaseManager sharedInstance] activeAccount];
_searchParticipantsTask = [[NCAPIController sharedInstance] getContactsForAccount:[[NCDatabaseManager sharedInstance] activeAccount] forRoom:_room.token forGroupRoom:YES withSearchParam:searchString completionBlock:^(NSArray<NCUser *> * _Nullable contactList, NSError *error) {
_searchParticipantsTask = [[NCAPIController sharedInstance] getContactsForAccount:[[NCDatabaseManager sharedInstance] activeAccount] forRoom:_room.token forGroupRoom:YES withSearchParam:searchString completionBlock:^(NSArray<NCUser *> * _Nullable contactList, OcsError *error) {
if (!error) {
NSMutableArray *storedContacts = [NCContact contactsForAccountId:activeAccount.accountId contains:searchString];
NSMutableArray *combinedContactList = [NCUser combineUsersArray:storedContacts withUsersArray:contactList];
NSMutableDictionary *participants = [NCUser indexedUsersFromUsersArray:combinedContactList];
NSArray *sortedIndexes = [[participants allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
[self->_resultTableViewController setSearchResultContacts:participants withIndexes:sortedIndexes];
} else {
if (error.code != -999) {
if ([error underlyingError].code != NSURLErrorCancelled) {
NSLog(@"Error while searching for participants: %@", error);
}
}
Expand Down
2 changes: 1 addition & 1 deletion NextcloudTalk/Contacts/NCContactsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ - (void)updateAddressBookCopyWithContacts:(NSArray *)contacts andTimestamp:(NSIn

- (void)searchForPhoneNumbers:(NSDictionary *)phoneNumbers forAccount:(TalkAccount *)account
{
[[NCAPIController sharedInstance] searchContactsForAccount:account withPhoneNumbers:phoneNumbers completionBlock:^(NSDictionary<NSString *,NSString *> * _Nullable contacts, NSError *error) {
[[NCAPIController sharedInstance] searchContactsForAccount:account withPhoneNumbers:phoneNumbers completionBlock:^(NSDictionary<NSString *,NSString *> * _Nullable contacts, OcsError *error) {
if (!error) {
BGTaskHelper *bgTask = [BGTaskHelper startBackgroundTaskWithName:@"NCUpdateContacts" expirationHandler:nil];
RLMRealm *realm = [RLMRealm defaultRealm];
Expand Down
Loading
Loading