Warn unknown devices: Add the screen that list unknown devices (UsersDevicesViewController)

This commit is contained in:
manuroe
2017-02-14 18:21:46 +01:00
parent cb8a1a8d39
commit 31a3fe657e
8 changed files with 356 additions and 10 deletions
+38 -3
View File
@@ -45,6 +45,8 @@
#import "RoomSearchViewController.h"
#import "UsersDevicesViewController.h"
#import "RoomIncomingTextMsgBubbleCell.h"
#import "RoomIncomingTextMsgWithoutSenderInfoBubbleCell.h"
#import "RoomIncomingTextMsgWithPaginationTitleBubbleCell.h"
@@ -137,6 +139,9 @@
// Potential encryption details view.
EncryptionInfoView *encryptionInfoView;
// The list of unknown devices that prevent outgoing messages from being sent
MXUsersDevicesMap<MXDeviceInfo*> *unknownDevices;
// Observe kAppDelegateDidTapStatusBarNotification to handle tap on clock status bar.
id kAppDelegateDidTapStatusBarNotificationObserver;
@@ -2247,6 +2252,16 @@
selectedContact = nil;
}
}
else if ([[segue identifier] isEqualToString:@"showUnknownDevices"])
{
if (unknownDevices)
{
UsersDevicesViewController *usersDevicesViewController = (UsersDevicesViewController *)segue.destinationViewController.childViewControllers.firstObject;
[usersDevicesViewController displayUsersDevices:unknownDevices andMatrixSession:self.roomDataSource.mxSession];
unknownDevices = nil;
}
}
// Hide back button title
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
@@ -3117,16 +3132,15 @@
style:MXKAlertStyleAlert];
currentAlert.cancelButtonIndex = [currentAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
typeof(self) self = weakSelf;
self->currentAlert = nil;
}];
[currentAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"unknown_devices_verify"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
// @TODO
typeof(self) self = weakSelf;
self->currentAlert = nil;
[self showUnknownDevices];
}];
currentAlert.mxkAccessibilityIdentifier = @"RoomVCUnknownDevicesAlert";
@@ -3134,6 +3148,27 @@
}
}
- (void)showUnknownDevices
{
// List all unknown devices
unknownDevices = [[MXUsersDevicesMap alloc] init];
NSArray<MXEvent*> *outgoingMsgs = self.roomDataSource.room.outgoingMessages;
for (MXEvent *event in outgoingMsgs)
{
if (event.sentState == MXEventSentStateFailed
&& [event.sentError.domain isEqualToString:MXEncryptingErrorDomain]
&& event.sentError.code == MXEncryptingErrorUnknownDeviceCode)
{
MXUsersDevicesMap<MXDeviceInfo*> *eventUnknownDevices = event.sentError.userInfo[MXEncryptingErrorUnknownDeviceDevicesKey];
[unknownDevices addEntriesFromMap:eventUnknownDevices];
}
}
[self performSegueWithIdentifier:@"showUnknownDevices" sender:self];
}
- (void)resendAllUnsentMessages
{
// List unsent event ids