Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 1 | /* |
Sébastien Blin | 029ffa8 | 2019-01-02 17:43:48 -0500 | [diff] [blame] | 2 | * Copyright (C) 2015-2019 Savoir-faire Linux Inc. |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 3 | * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com> |
| 4 | * Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | */ |
| 20 | #import "AccRingGeneralVC.h" |
| 21 | |
| 22 | //cocoa |
| 23 | #import <Quartz/Quartz.h> |
Kateryna Kostiuk | 91b44e3 | 2018-09-28 17:08:02 -0400 | [diff] [blame] | 24 | #import <AVFoundation/AVFoundation.h> |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 25 | |
| 26 | |
| 27 | //Qt |
| 28 | #import <QSize> |
| 29 | #import <QtMacExtras/qmacfunctions.h> |
| 30 | #import <QPixmap> |
| 31 | |
| 32 | //LRC |
| 33 | #import <api/lrc.h> |
| 34 | #import <api/newaccountmodel.h> |
| 35 | #import <api/newdevicemodel.h> |
| 36 | #import <interfaces/pixmapmanipulatori.h> |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 37 | |
| 38 | #import "RegisterNameWC.h" |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 39 | #import "views/NSColor+RingTheme.h" |
| 40 | #import "views/NSImage+Extensions.h" |
| 41 | #import "views/HoverTableRowView.h" |
Kateryna Kostiuk | 9fca542 | 2018-11-19 16:27:46 -0500 | [diff] [blame] | 42 | #import "views/RoundedTextField.h" |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 43 | #import "ExportPasswordWC.h" |
| 44 | #import "utils.h" |
Kateryna Kostiuk | 2f2ef95 | 2019-05-07 11:04:41 -0400 | [diff] [blame] | 45 | #import "Constants.h" |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 46 | |
| 47 | @interface AccRingGeneralVC () |
| 48 | |
| 49 | @property (unsafe_unretained) IBOutlet NSTextField *displayNameField; |
| 50 | @property (unsafe_unretained) IBOutlet NSTextField *ringIDField; |
| 51 | @property (unsafe_unretained) IBOutlet NSTextField *registeredNameField; |
Kateryna Kostiuk | c7e68f3 | 2019-10-09 16:15:45 -0400 | [diff] [blame] | 52 | @property (unsafe_unretained) IBOutlet NSTextField *passwordField; |
Kateryna Kostiuk | 9fca542 | 2018-11-19 16:27:46 -0500 | [diff] [blame] | 53 | @property (unsafe_unretained) IBOutlet RoundedTextField *accountStatus; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 54 | @property (unsafe_unretained) IBOutlet NSButton *registerNameButton; |
| 55 | @property (unsafe_unretained) IBOutlet NSButton* photoView; |
| 56 | @property (unsafe_unretained) IBOutlet NSButton* passwordButton; |
Kateryna Kostiuk | c7e68f3 | 2019-10-09 16:15:45 -0400 | [diff] [blame] | 57 | @property (unsafe_unretained) IBOutlet NSButton* linkDeviceButton; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 58 | @property (unsafe_unretained) IBOutlet NSButton* removeAccountButton; |
Kateryna Kostiuk | 2d621cb | 2019-10-25 18:57:32 -0400 | [diff] [blame] | 59 | @property (unsafe_unretained) IBOutlet NSButton* exportAccountButton; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 60 | @property (unsafe_unretained) IBOutlet NSImageView* addProfilePhotoImage; |
| 61 | @property (unsafe_unretained) IBOutlet NSTableView* devicesTableView; |
| 62 | @property (unsafe_unretained) IBOutlet NSTableView* blockedContactsTableView; |
| 63 | @property (assign) IBOutlet NSLayoutConstraint* buttonRegisterWidthConstraint; |
| 64 | @property (assign) IBOutlet NSLayoutConstraint* bannedContactHeightConstraint; |
| 65 | @property (assign) IBOutlet NSLayoutConstraint* advancedButtonMarginConstraint; |
| 66 | |
| 67 | |
| 68 | @property AbstractLoadingWC* accountModal; |
| 69 | @property PasswordChangeWC* passwordModal; |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 70 | @property QString selectedAccountID; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 71 | |
| 72 | @end |
| 73 | |
| 74 | @implementation AccRingGeneralVC |
| 75 | |
| 76 | QMetaObject::Connection deviceAddedSignal; |
| 77 | QMetaObject::Connection deviceRevokedSignal; |
| 78 | QMetaObject::Connection deviceUpdatedSignal; |
| 79 | QMetaObject::Connection contactBlockedSignal; |
| 80 | QMetaObject::Connection bannedContactsChangedSignal; |
Kateryna Kostiuk | 9fca542 | 2018-11-19 16:27:46 -0500 | [diff] [blame] | 81 | QMetaObject::Connection accountStateChangedSignal; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 82 | |
| 83 | |
| 84 | @synthesize displayNameField; |
| 85 | @synthesize ringIDField; |
| 86 | @synthesize registeredNameField; |
| 87 | @synthesize photoView; |
| 88 | @synthesize addProfilePhotoImage; |
| 89 | @synthesize accountModel; |
| 90 | @synthesize registerNameButton, passwordButton, removeAccountButton; |
| 91 | @synthesize buttonRegisterWidthConstraint; |
| 92 | @synthesize accountModal; |
| 93 | @synthesize delegate; |
| 94 | @synthesize devicesTableView; |
| 95 | @synthesize blockedContactsTableView; |
Kateryna Kostiuk | c7e68f3 | 2019-10-09 16:15:45 -0400 | [diff] [blame] | 96 | @synthesize linkDeviceButton; |
| 97 | @synthesize passwordField; |
Kateryna Kostiuk | 2d621cb | 2019-10-25 18:57:32 -0400 | [diff] [blame] | 98 | @synthesize exportAccountButton; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 99 | |
| 100 | typedef NS_ENUM(NSInteger, TagViews) { |
| 101 | DISPLAYNAME = 100, |
| 102 | DEVICE_NAME_TAG = 200, |
| 103 | DEVICE_ID_TAG = 300, |
| 104 | DEVICE_EDIT_TAG = 400, |
| 105 | DEVICE_REVOKE_TAG = 500, |
| 106 | BANNED_CONTACT_NAME_TAG = 600, |
| 107 | BANNED_CONTACT_ID_TAG = 700, |
| 108 | UNBLOCK_CONTACT_TAG = 800 |
| 109 | }; |
| 110 | |
| 111 | -(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountmodel:(lrc::api::NewAccountModel*) accountModel |
| 112 | { |
| 113 | if (self = [self initWithNibName: nibNameOrNil bundle:nibBundleOrNil]) |
| 114 | { |
| 115 | self.accountModel= accountModel; |
| 116 | } |
| 117 | return self; |
| 118 | } |
| 119 | |
| 120 | - (void)awakeFromNib |
| 121 | { |
| 122 | [super awakeFromNib]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 123 | [addProfilePhotoImage setWantsLayer: YES]; |
| 124 | devicesTableView.delegate = self; |
| 125 | devicesTableView.dataSource = self; |
| 126 | blockedContactsTableView.delegate = self; |
| 127 | blockedContactsTableView.dataSource= self; |
Kateryna Kostiuk | 782ac77 | 2019-11-29 16:12:30 -0500 | [diff] [blame] | 128 | [[self view] setAutoresizingMask: NSViewMinXMargin | NSViewMaxXMargin | NSViewWidthSizable]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | - (void)viewDidLoad { |
| 132 | [super viewDidLoad]; |
| 133 | [self updateView]; |
| 134 | } |
| 135 | |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 136 | - (void) setSelectedAccount:(const QString&) account { |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 137 | self.selectedAccountID = account; |
| 138 | [self connectSignals]; |
| 139 | [self updateView]; |
| 140 | [self hideBannedContacts]; |
| 141 | } |
| 142 | |
| 143 | -(void) updateView { |
| 144 | const auto& account = accountModel->getAccountInfo(self.selectedAccountID); |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 145 | |
Kateryna Kostiuk | dc72084 | 2020-09-10 16:44:02 -0400 | [diff] [blame] | 146 | @autoreleasepool { |
| 147 | NSData *imageData = [[NSData alloc] initWithBase64EncodedString:account.profileInfo.avatar.toNSString() options:NSDataBase64DecodingIgnoreUnknownCharacters]; |
| 148 | NSImage *image = [[NSImage alloc] initWithData:imageData]; |
| 149 | if(image) { |
| 150 | [photoView setBordered:NO]; |
| 151 | [photoView setImage: [image roundCorners: image.size.height * 0.5]]; |
| 152 | [addProfilePhotoImage setHidden:YES]; |
| 153 | } else { |
| 154 | [photoView setImage:nil]; |
| 155 | [photoView setBordered:YES]; |
| 156 | [addProfilePhotoImage setHidden:NO]; |
| 157 | } |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 158 | } |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 159 | NSString* displayName = account.profileInfo.alias.toNSString(); |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 160 | [displayNameField setStringValue:displayName]; |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 161 | [ringIDField setStringValue: account.profileInfo.uri.toNSString()]; |
Kateryna Kostiuk | 9a2791a | 2019-10-28 10:38:11 -0400 | [diff] [blame] | 162 | |
| 163 | lrc::api::account::ConfProperties_t accountProperties = self.accountModel->getAccountConfig(self.selectedAccountID); |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 164 | bool hideLocalAccountConfig = !accountProperties.managerUri.isEmpty(); |
Kateryna Kostiuk | 9a2791a | 2019-10-28 10:38:11 -0400 | [diff] [blame] | 165 | [passwordButton setHidden:hideLocalAccountConfig]; |
| 166 | [linkDeviceButton setHidden:hideLocalAccountConfig]; |
| 167 | [passwordField setHidden:hideLocalAccountConfig]; |
| 168 | [exportAccountButton setHidden: hideLocalAccountConfig]; |
| 169 | |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 170 | if(account.registeredName.isEmpty() && !hideLocalAccountConfig) { |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 171 | [registerNameButton setHidden:NO]; |
| 172 | buttonRegisterWidthConstraint.constant = 260.0; |
| 173 | } else { |
| 174 | buttonRegisterWidthConstraint.constant = 0.0; |
| 175 | [registerNameButton setHidden:YES]; |
| 176 | } |
| 177 | |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 178 | [registeredNameField setStringValue:account.registeredName.toNSString()]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 179 | |
Kateryna Kostiuk | 92a3032 | 2020-05-08 11:11:52 -0400 | [diff] [blame] | 180 | NSString *title = accountProperties.archiveHasPassword ? |
| 181 | NSLocalizedString(@"Change password", @"Password button title") : |
| 182 | NSLocalizedString(@"Create password", @"Password button title"); |
| 183 | |
| 184 | [passwordButton setTitle:title]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 185 | self.accountEnabled = account.enabled; |
| 186 | |
| 187 | NSMutableAttributedString *colorTitle = [[NSMutableAttributedString alloc] initWithAttributedString:[removeAccountButton attributedTitle]]; |
| 188 | NSRange titleRange = NSMakeRange(0, [colorTitle length]); |
| 189 | [colorTitle addAttribute:NSForegroundColorAttributeName value:[NSColor errorColor] range:titleRange]; |
| 190 | [removeAccountButton setAttributedTitle:colorTitle]; |
| 191 | [devicesTableView reloadData]; |
| 192 | [blockedContactsTableView reloadData]; |
Kateryna Kostiuk | 9fca542 | 2018-11-19 16:27:46 -0500 | [diff] [blame] | 193 | self.accountStatus.bgColor = colorForAccountStatus(accountModel->getAccountInfo(self.selectedAccountID).status); |
| 194 | [self.accountStatus setNeedsDisplay:YES]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | -(void) connectSignals { |
| 198 | QObject::disconnect(deviceAddedSignal); |
| 199 | QObject::disconnect(deviceRevokedSignal); |
| 200 | QObject::disconnect(deviceUpdatedSignal); |
| 201 | QObject::disconnect(bannedContactsChangedSignal); |
Kateryna Kostiuk | 9fca542 | 2018-11-19 16:27:46 -0500 | [diff] [blame] | 202 | QObject::disconnect(accountStateChangedSignal); |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 203 | deviceAddedSignal = QObject::connect(&*(self.accountModel->getAccountInfo(self.selectedAccountID)).deviceModel, |
| 204 | &lrc::api::NewDeviceModel::deviceAdded, |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 205 | [self] (const QString& id) { |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 206 | [devicesTableView reloadData]; |
| 207 | }); |
| 208 | deviceRevokedSignal = QObject::connect(&*(self.accountModel->getAccountInfo(self.selectedAccountID)).deviceModel, |
| 209 | &lrc::api::NewDeviceModel::deviceRevoked, |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 210 | [self] (const QString& id, const lrc::api::NewDeviceModel::Status status) { |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 211 | switch (status) { |
| 212 | case lrc::api::NewDeviceModel::Status::SUCCESS: |
| 213 | [devicesTableView reloadData]; |
| 214 | break; |
| 215 | case lrc::api::NewDeviceModel::Status::WRONG_PASSWORD: |
Kateryna Kostiuk | 92a3032 | 2020-05-08 11:11:52 -0400 | [diff] [blame] | 216 | [self showAlertWithTitle: @"" andText: NSLocalizedString(@"Device revocation failed. Please check your password and try again.", @"Device revocation error")]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 217 | break; |
| 218 | case lrc::api::NewDeviceModel::Status::UNKNOWN_DEVICE: |
Kateryna Kostiuk | 92a3032 | 2020-05-08 11:11:52 -0400 | [diff] [blame] | 219 | [self showAlertWithTitle: @"" andText: NSLocalizedString(@"Device revocation failed", @"Device revocation error")]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 220 | break; |
| 221 | } |
| 222 | }); |
| 223 | deviceUpdatedSignal = QObject::connect(&*(self.accountModel->getAccountInfo(self.selectedAccountID)).deviceModel, |
| 224 | &lrc::api::NewDeviceModel::deviceUpdated, |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 225 | [self] (const QString& id) { |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 226 | [devicesTableView reloadData]; |
| 227 | }); |
| 228 | bannedContactsChangedSignal = QObject::connect(&*(self.accountModel->getAccountInfo(self.selectedAccountID)).contactModel, |
| 229 | &lrc::api::ContactModel::bannedStatusChanged, |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 230 | [self] (const QString& contactUri, bool banned) { |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 231 | [blockedContactsTableView reloadData]; |
| 232 | }); |
Kateryna Kostiuk | 9fca542 | 2018-11-19 16:27:46 -0500 | [diff] [blame] | 233 | accountStateChangedSignal = QObject::connect(self.accountModel, |
| 234 | &lrc::api::NewAccountModel::accountStatusChanged, |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 235 | [self] (const QString& accountID) { |
Kateryna Kostiuk | 9fca542 | 2018-11-19 16:27:46 -0500 | [diff] [blame] | 236 | if(accountID != self.selectedAccountID) { |
| 237 | return; |
| 238 | } |
| 239 | self.accountStatus.bgColor = colorForAccountStatus(accountModel->getAccountInfo(accountID).status); |
| 240 | [self.accountStatus setNeedsDisplay:YES]; |
| 241 | }); |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | -(void) showAlertWithTitle: (NSString *) title andText: (NSString *)text { |
| 245 | NSAlert *alert = [[NSAlert alloc] init]; |
| 246 | [alert addButtonWithTitle:@"OK"]; |
| 247 | [alert setMessageText:title]; |
| 248 | [alert setInformativeText:text]; |
| 249 | [alert runModal]; |
| 250 | } |
| 251 | |
| 252 | - (void)pictureTakerDidEnd:(IKPictureTaker *) picker |
| 253 | returnCode:(NSInteger) code |
| 254 | contextInfo:(void*) contextInfo |
| 255 | { |
Kateryna Kostiuk | 14b8aa7 | 2020-11-11 10:40:15 -0500 | [diff] [blame] | 256 | //do nothing when editing canceled |
Kateryna Kostiuk | 256814e | 2018-09-04 14:47:33 -0400 | [diff] [blame] | 257 | if (code == 0) { |
| 258 | return; |
| 259 | } |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 260 | if (auto outputImage = [picker outputImage]) { |
| 261 | auto image = [picker inputImage]; |
Kateryna Kostiuk | 2f2ef95 | 2019-05-07 11:04:41 -0400 | [diff] [blame] | 262 | CGFloat newSize = MIN(MIN(image.size.height, image.size.width), MAX_IMAGE_SIZE); |
| 263 | outputImage = [outputImage imageResizeInsideMax: newSize]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 264 | [photoView setImage: [outputImage roundCorners: outputImage.size.height * 0.5]]; |
Kateryna Kostiuk | 39ce23d | 2018-10-02 14:33:37 -0400 | [diff] [blame] | 265 | [photoView setBordered:NO]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 266 | [addProfilePhotoImage setHidden:YES]; |
Kateryna Kostiuk | 14b8aa7 | 2020-11-11 10:40:15 -0500 | [diff] [blame] | 267 | NSData* imageData = [outputImage TIFFRepresentation]; |
| 268 | NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData: imageData]; |
| 269 | NSDictionary *properties = [[NSDictionary alloc] init]; |
| 270 | imageData = [imageRep representationUsingType:NSPNGFileType properties: properties]; |
| 271 | NSString * dataString = [imageData base64EncodedStringWithOptions:0]; |
| 272 | self.accountModel->setAvatar(self.selectedAccountID, QString::fromNSString(dataString)); |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 273 | } else if(!photoView.image) { |
Kateryna Kostiuk | 39ce23d | 2018-10-02 14:33:37 -0400 | [diff] [blame] | 274 | [photoView setBordered:YES]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 275 | [addProfilePhotoImage setHidden:NO]; |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | #pragma mark - RegisterNameDelegate methods |
| 280 | |
| 281 | - (void) didRegisterName:(NSString *) name withSuccess:(BOOL) success |
| 282 | { |
| 283 | [self.accountModal close]; |
| 284 | if(!success) { |
| 285 | return; |
| 286 | } |
| 287 | |
| 288 | if(name.length == 0) { |
| 289 | return; |
| 290 | } |
| 291 | buttonRegisterWidthConstraint.constant = 0.0; |
| 292 | [registerNameButton setHidden:YES]; |
| 293 | [registeredNameField setStringValue:name]; |
Kateryna Kostiuk | df68076 | 2018-10-29 13:53:52 -0400 | [diff] [blame] | 294 | lrc::api::account::ConfProperties_t accountProperties = self.accountModel->getAccountConfig(self.selectedAccountID); |
| 295 | self.accountModel->setAccountConfig(self.selectedAccountID, accountProperties); |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | #pragma mark - NSTextFieldDelegate delegate methods |
| 299 | |
| 300 | - (void)controlTextDidChange:(NSNotification *)notif |
| 301 | { |
| 302 | NSTextField* textField = [notif object]; |
| 303 | if (textField.tag != DISPLAYNAME) { |
| 304 | return; |
| 305 | } |
| 306 | NSString* displayName = textField.stringValue; |
| 307 | |
| 308 | [NSObject cancelPreviousPerformRequestsWithTarget:self]; |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 309 | self.accountModel->setAlias(self.selectedAccountID, QString::fromNSString(displayName)); |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 310 | lrc::api::account::ConfProperties_t accountProperties = self.accountModel->getAccountConfig(self.selectedAccountID); |
| 311 | self.accountModel->setAccountConfig(self.selectedAccountID, accountProperties); |
| 312 | } |
| 313 | |
| 314 | #pragma mark - NSTableViewDataSource methods |
| 315 | |
| 316 | - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView { |
| 317 | if(tableView == devicesTableView) { |
| 318 | return self.accountModel->getAccountInfo(self.selectedAccountID).deviceModel->getAllDevices().size(); |
| 319 | } else if (tableView == blockedContactsTableView){ |
| 320 | return self.accountModel->getAccountInfo(self.selectedAccountID).contactModel->getBannedContacts().size(); |
| 321 | } |
| 322 | return 0; |
| 323 | } |
| 324 | |
| 325 | #pragma mark - NSTableViewDelegate methods |
| 326 | - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row |
| 327 | { |
| 328 | if(tableView == devicesTableView) { |
| 329 | NSTableCellView* deviceView = [tableView makeViewWithIdentifier:@"TableCellDeviceItem" owner:self]; |
| 330 | NSTextField* nameLabel = [deviceView viewWithTag: DEVICE_NAME_TAG]; |
| 331 | NSTextField* idLabel = [deviceView viewWithTag: DEVICE_ID_TAG]; |
| 332 | NSButton* revokeButton = [deviceView viewWithTag: DEVICE_REVOKE_TAG]; |
| 333 | NSButton* editButton = [deviceView viewWithTag: DEVICE_EDIT_TAG]; |
| 334 | [editButton setAction:@selector(editDevice:)]; |
| 335 | [editButton setTarget:self]; |
| 336 | [revokeButton setAction:@selector(startDeviceRevocation:)]; |
| 337 | [revokeButton setTarget:self]; |
| 338 | auto devices = self.accountModel->getAccountInfo(self.selectedAccountID).deviceModel->getAllDevices(); |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 339 | auto device = devices[row]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 340 | |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 341 | auto name = device.name; |
| 342 | auto deviceID = device.id; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 343 | |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 344 | [nameLabel setStringValue: name.toNSString()]; |
| 345 | [idLabel setStringValue: deviceID.toNSString()]; |
| 346 | [revokeButton setHidden: device.isCurrent]; |
| 347 | [editButton setHidden: !device.isCurrent]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 348 | return deviceView; |
| 349 | } else if (tableView == blockedContactsTableView) { |
| 350 | NSTableCellView* contactView = [tableView makeViewWithIdentifier:@"TableCellBannedContactItem" owner:self]; |
| 351 | NSTextField* nameLabel = [contactView viewWithTag: BANNED_CONTACT_NAME_TAG]; |
| 352 | NSTextField* idLabel = [contactView viewWithTag: BANNED_CONTACT_ID_TAG]; |
| 353 | NSButton* revokeButton = [contactView viewWithTag: UNBLOCK_CONTACT_TAG]; |
| 354 | auto contacts = self.accountModel->getAccountInfo(self.selectedAccountID).contactModel->getBannedContacts(); |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 355 | auto contactID = contacts[row]; |
| 356 | [idLabel setStringValue: contactID.toNSString()]; |
| 357 | try { |
| 358 | auto contact = self.accountModel->getAccountInfo(self.selectedAccountID).contactModel->getContact(contactID); |
| 359 | [nameLabel setStringValue: bestNameForContact(contact)]; |
| 360 | } catch (std::out_of_range& e) { |
| 361 | NSLog(@"contact out of range"); |
| 362 | } |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 363 | [revokeButton setAction:@selector(unblockContact:)]; |
| 364 | [revokeButton setTarget:self]; |
| 365 | return contactView; |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row |
| 370 | { |
| 371 | if(tableView == devicesTableView) { |
| 372 | return tableView.rowHeight; |
| 373 | } else if (tableView == blockedContactsTableView) { |
| 374 | CGFloat height = self.bannedContactHeightConstraint.constant; |
| 375 | if(height == 150) { |
| 376 | return 52; |
| 377 | } else { |
| 378 | return 1; |
| 379 | } |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | - (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row |
| 384 | { |
| 385 | return [tableView makeViewWithIdentifier:@"HoverRowView" owner:nil]; |
| 386 | } |
| 387 | |
| 388 | #pragma mark - Actions |
| 389 | |
| 390 | - (IBAction)editPhoto:(id)sender |
| 391 | { |
| 392 | auto pictureTaker = [IKPictureTaker pictureTaker]; |
Kateryna Kostiuk | dc56324 | 2019-08-19 12:05:54 -0400 | [diff] [blame] | 393 | #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 |
Kateryna Kostiuk | 91b44e3 | 2018-09-28 17:08:02 -0400 | [diff] [blame] | 394 | if (@available(macOS 10.14, *)) { |
| 395 | AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; |
| 396 | if(authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied) |
| 397 | { |
| 398 | [pictureTaker setValue:0 forKey:IKPictureTakerAllowsVideoCaptureKey]; |
| 399 | } |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 400 | |
Kateryna Kostiuk | 91b44e3 | 2018-09-28 17:08:02 -0400 | [diff] [blame] | 401 | if(authStatus == AVAuthorizationStatusNotDetermined) |
| 402 | { |
| 403 | [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) { |
| 404 | if(!granted){ |
| 405 | [pictureTaker setValue:0 forKey:IKPictureTakerAllowsVideoCaptureKey]; |
| 406 | } |
| 407 | }]; |
| 408 | } |
| 409 | } |
Kateryna Kostiuk | dc56324 | 2019-08-19 12:05:54 -0400 | [diff] [blame] | 410 | #endif |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 411 | [pictureTaker beginPictureTakerSheetForWindow:[self.view window] |
| 412 | withDelegate:self |
| 413 | didEndSelector:@selector(pictureTakerDidEnd:returnCode:contextInfo:) |
| 414 | contextInfo:nil]; |
| 415 | |
| 416 | } |
| 417 | |
| 418 | - (IBAction)startExportOnRing:(id)sender |
| 419 | { |
| 420 | ExportPasswordWC *passwordWC = [[ExportPasswordWC alloc] initWithNibName:@"ExportPasswordWindow" bundle: nil accountmodel: self.accountModel]; |
| 421 | passwordWC.selectedAccountID = self.selectedAccountID; |
| 422 | accountModal = passwordWC; |
| 423 | [self.view.window beginSheet: passwordWC.window completionHandler:nil]; |
| 424 | } |
| 425 | - (IBAction)triggerAdwancedSettings: (NSButton *)sender { |
| 426 | [self.delegate triggerAdvancedOptions]; |
| 427 | } |
| 428 | |
| 429 | - (IBAction)enableAccount: (NSButton *)sender { |
| 430 | const auto& account = accountModel->getAccountInfo(self.selectedAccountID); |
Kateryna Kostiuk | 5379964 | 2019-07-30 18:21:16 -0400 | [diff] [blame] | 431 | self.accountModel->setAccountEnabled(self.selectedAccountID, !account.enabled); |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 432 | self.accountEnabled = account.enabled; |
Kateryna Kostiuk | 5379964 | 2019-07-30 18:21:16 -0400 | [diff] [blame] | 433 | |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | - (IBAction)removeAccount:(id)sender |
| 437 | { |
| 438 | NSAlert *alert = [[NSAlert alloc] init]; |
| 439 | [alert addButtonWithTitle:@"OK"]; |
Kateryna Kostiuk | 92a3032 | 2020-05-08 11:11:52 -0400 | [diff] [blame] | 440 | [alert addButtonWithTitle:NSLocalizedString(@"Cancel",@"Button Action")]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 441 | [alert setMessageText: NSLocalizedString(@"Remove account", |
| 442 | @"Remove account alert title")]; |
| 443 | [alert setInformativeText:NSLocalizedString(@"By clicking \"OK\" you will remove this account on this device! This action can not be undone. Also, your registered name can be lost.", |
| 444 | @"Remove account alert message")]; |
| 445 | |
| 446 | if ([alert runModal] == NSAlertFirstButtonReturn) { |
| 447 | self.accountModel->removeAccount(self.selectedAccountID); |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | - (IBAction)exportAccount:(id)sender |
| 452 | { |
Kateryna Kostiuk | 740a596 | 2019-03-28 12:56:08 -0400 | [diff] [blame] | 453 | NSSavePanel* filePicker = [NSSavePanel savePanel]; |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 454 | NSString* name = [self.selectedAccountID.toNSString() stringByAppendingString: @".gz"]; |
Kateryna Kostiuk | 740a596 | 2019-03-28 12:56:08 -0400 | [diff] [blame] | 455 | [filePicker setNameFieldStringValue: name]; |
Kateryna Kostiuk | f4b1a79 | 2019-09-19 11:26:19 -0400 | [diff] [blame] | 456 | if ([filePicker runModal] != NSFileHandlingPanelOKButton) { |
| 457 | return; |
| 458 | } |
| 459 | NSString *password = @""; |
| 460 | const char* fullPath = [[filePicker URL] fileSystemRepresentation]; |
| 461 | lrc::api::account::ConfProperties_t accountProperties = self.accountModel->getAccountConfig(self.selectedAccountID); |
| 462 | if(accountProperties.archiveHasPassword) { |
| 463 | NSAlert *alert = [[NSAlert alloc] init]; |
| 464 | [alert addButtonWithTitle:@"OK"]; |
Kateryna Kostiuk | 92a3032 | 2020-05-08 11:11:52 -0400 | [diff] [blame] | 465 | [alert addButtonWithTitle:NSLocalizedString(@"Cancel",@"Button Action")]; |
Kateryna Kostiuk | f4b1a79 | 2019-09-19 11:26:19 -0400 | [diff] [blame] | 466 | [alert setMessageText: NSLocalizedString(@"Enter account password", |
| 467 | @"Backup enter password")]; |
| 468 | NSTextField *input = [[NSSecureTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 20)]; |
| 469 | [alert setAccessoryView:input]; |
| 470 | if ([alert runModal] != NSAlertFirstButtonReturn) { |
| 471 | return; |
Kateryna Kostiuk | 740a596 | 2019-03-28 12:56:08 -0400 | [diff] [blame] | 472 | } |
Kateryna Kostiuk | f4b1a79 | 2019-09-19 11:26:19 -0400 | [diff] [blame] | 473 | password = [input stringValue]; |
| 474 | } |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 475 | if (self.accountModel->exportToFile(self.selectedAccountID, fullPath, QString::fromNSString(password))) { |
Kateryna Kostiuk | f4b1a79 | 2019-09-19 11:26:19 -0400 | [diff] [blame] | 476 | [self didCompleteExportWithPath:[filePicker URL]]; |
| 477 | } else { |
| 478 | [self showAlertWithTitle: @"" andText: NSLocalizedString(@"An error occured during the backup", @"Backup error")]; |
Kateryna Kostiuk | 740a596 | 2019-03-28 12:56:08 -0400 | [diff] [blame] | 479 | } |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | - (IBAction)startNameRegistration:(id)sender |
| 483 | { |
| 484 | RegisterNameWC* registerWC = [[RegisterNameWC alloc] initWithNibName:@"RegisterNameWindow" bundle: nil accountmodel: self.accountModel]; |
| 485 | registerWC.delegate = self; |
| 486 | registerWC.selectedAccountID = self.selectedAccountID; |
| 487 | self.accountModal = registerWC; |
| 488 | [self.view.window beginSheet:registerWC.window completionHandler:nil]; |
| 489 | } |
| 490 | - (IBAction)changePassword:(id)sender |
| 491 | { |
| 492 | PasswordChangeWC* passwordWC = [[PasswordChangeWC alloc] initWithNibName:@"PasswordChange" bundle: nil accountmodel: self.accountModel]; |
| 493 | passwordWC.selectedAccountID = self.selectedAccountID; |
| 494 | passwordWC.delegate = self; |
| 495 | [self.view.window beginSheet:passwordWC.window completionHandler:nil]; |
| 496 | self.passwordModal = passwordWC; |
| 497 | } |
| 498 | |
| 499 | - (IBAction)showBanned: (NSButton *)sender { |
| 500 | CGFloat height = self.bannedContactHeightConstraint.constant; |
| 501 | NSRect frame = self.view.frame; |
| 502 | if(height == 150) { |
| 503 | frame.size.height = frame.size.height - 150 - 10; |
| 504 | } else { |
| 505 | frame.size.height = frame.size.height + 150 + 10; |
| 506 | } |
| 507 | self.view.frame = frame; |
| 508 | [self.delegate updateFrame]; |
| 509 | CGFloat advancedHeight = self.advancedButtonMarginConstraint.constant; |
| 510 | self.advancedButtonMarginConstraint.constant = (height== 2) ? 40 : 30; |
| 511 | self.bannedContactHeightConstraint.constant = (height== 2) ? 150 : 2; |
Kateryna Kostiuk | 394f74c | 2018-10-05 15:45:26 -0400 | [diff] [blame] | 512 | [[[[self.blockedContactsTableView superview] superview] superview] setHidden:![[[[self.blockedContactsTableView superview] superview] superview] isHidden]]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 513 | [blockedContactsTableView reloadData]; |
| 514 | } |
| 515 | |
| 516 | -(void) hideBannedContacts { |
| 517 | CGFloat height = self.bannedContactHeightConstraint.constant; |
| 518 | NSRect frame = self.view.frame; |
| 519 | if(height == 150) { |
| 520 | [self showBanned:nil]; |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | - (IBAction)startDeviceRevocation:(NSView*)sender |
| 525 | { |
| 526 | NSInteger row = [devicesTableView rowForView:sender]; |
| 527 | if(row < 0) { |
| 528 | return; |
| 529 | } |
| 530 | auto devices = self.accountModel->getAccountInfo(self.selectedAccountID).deviceModel->getAllDevices(); |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 531 | if (devices.size() < row) { |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 532 | return; |
| 533 | } |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 534 | auto device = devices[row]; |
| 535 | [self proceedDeviceRevokationAlert:device.id]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | - (IBAction)unblockContact:(NSView*)sender |
| 539 | { |
| 540 | NSInteger row = [blockedContactsTableView rowForView:sender]; |
| 541 | if(row < 0) { |
| 542 | return; |
| 543 | } |
| 544 | auto contacts = self.accountModel->getAccountInfo(self.selectedAccountID).contactModel->getBannedContacts(); |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 545 | auto contactID = contacts[row]; |
| 546 | try { |
| 547 | auto contact = self.accountModel->getAccountInfo(self.selectedAccountID).contactModel->getContact(contactID); |
| 548 | if(!contact.isBanned) { |
| 549 | return; |
| 550 | } |
| 551 | self.accountModel->getAccountInfo(self.selectedAccountID).contactModel->addContact(contact); |
| 552 | } catch (std::out_of_range& e) { |
| 553 | NSLog(@"contact out of range"); |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 554 | } |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | - (IBAction)editDevice:(NSView*)sender |
| 558 | { |
| 559 | NSInteger row = [devicesTableView rowForView:sender]; |
| 560 | if(row < 0) { |
| 561 | return; |
| 562 | } |
| 563 | |
| 564 | NSTableCellView* deviceView = [devicesTableView viewAtColumn:0 row:row makeIfNecessary:NO]; |
| 565 | if(!deviceView || ![deviceView isKindOfClass:[NSTableCellView class]]) { |
| 566 | return; |
| 567 | } |
| 568 | |
| 569 | NSTextField* nameLabel = [deviceView viewWithTag: DEVICE_NAME_TAG]; |
| 570 | NSButton* editButton = [deviceView viewWithTag: DEVICE_EDIT_TAG]; |
| 571 | if ([nameLabel isEditable]) { |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 572 | self.accountModel->getAccountInfo(self.selectedAccountID).deviceModel->setCurrentDeviceName(QString::fromNSString(nameLabel.stringValue)); |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 573 | [nameLabel setEditable:NO]; |
| 574 | [self.view.window makeFirstResponder:nil]; |
| 575 | editButton.image = [NSImage imageNamed:NSImageNameTouchBarComposeTemplate]; |
| 576 | return; |
| 577 | } |
| 578 | [nameLabel setEditable:YES]; |
| 579 | [nameLabel becomeFirstResponder]; |
| 580 | editButton.image = [NSImage imageNamed:NSImageNameTouchBarDownloadTemplate]; |
| 581 | } |
| 582 | |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 583 | -(void) revokeDeviceWithID: (const QString&) deviceID password:(NSString *) password { |
| 584 | self.accountModel->getAccountInfo(self.selectedAccountID).deviceModel->revokeDevice(deviceID, QString::fromNSString(password)); |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 585 | } |
| 586 | |
Kateryna Kostiuk | c867eb9 | 2020-03-08 13:15:17 -0400 | [diff] [blame] | 587 | -(void) proceedDeviceRevokationAlert: (const QString&) deviceID { |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 588 | NSAlert *alert = [[NSAlert alloc] init]; |
| 589 | [alert addButtonWithTitle:@"OK"]; |
Kateryna Kostiuk | 92a3032 | 2020-05-08 11:11:52 -0400 | [diff] [blame] | 590 | [alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"Button Action")]; |
| 591 | [alert setMessageText:NSLocalizedString(@"Revoke Device", @"Device revocation title")]; |
| 592 | [alert setInformativeText:NSLocalizedString(@"Attention! This action could not be undone!", |
| 593 | @"Device revocation message")]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 594 | lrc::api::account::ConfProperties_t accountProperties = self.accountModel->getAccountConfig(self.selectedAccountID); |
| 595 | if(accountProperties.archiveHasPassword) { |
| 596 | NSSecureTextField *passwordText = [[NSSecureTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 24)]; |
Kateryna Kostiuk | 92a3032 | 2020-05-08 11:11:52 -0400 | [diff] [blame] | 597 | [passwordText setPlaceholderString:NSLocalizedString(@"Enter account password", @"Backup enter password")]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 598 | [alert setAccessoryView:passwordText]; |
| 599 | if ([alert runModal] == NSAlertFirstButtonReturn) { |
| 600 | [self revokeDeviceWithID:deviceID password:[passwordText stringValue]]; |
| 601 | } |
| 602 | } else { |
| 603 | if ([alert runModal] == NSAlertFirstButtonReturn) { |
| 604 | [self revokeDeviceWithID:deviceID password:@""]; |
| 605 | } |
| 606 | } |
| 607 | } |
| 608 | |
| 609 | #pragma mark - BackupAccountDelegate methods |
| 610 | |
| 611 | -(void) didCompleteExportWithPath:(NSURL*) fileUrl |
| 612 | { |
| 613 | [[NSWorkspace sharedWorkspace] selectFile:fileUrl.path inFileViewerRootedAtPath:@""]; |
| 614 | } |
| 615 | |
| 616 | #pragma mark - PasswordChangeDelegate |
| 617 | |
| 618 | -(void) paswordCreatedWithSuccess:(BOOL) success |
| 619 | { |
Kateryna Kostiuk | 92a3032 | 2020-05-08 11:11:52 -0400 | [diff] [blame] | 620 | NSString *title = success ? NSLocalizedString(@"Change password", @"Password button title") : |
| 621 | NSLocalizedString(@"Create password", @"Password button title"); |
| 622 | [passwordButton setTitle: title]; |
Kateryna Kostiuk | 1f8c125 | 2018-07-30 18:18:57 -0400 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | @end |