Commit 1f8c125f authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

account settings: link to new lrc

This patch use new lrc to manage account settings and refactor
account ui. Due to the changes next views were removed:
-AccountsVC
-AccMediaVC
-AccDevicesVC
-AccSecurityVC
-AccRingVC

Change-Id: I08ddfc7be3bc2d71d646c8f18cf3d1980378142c
Reviewed-by: Andreas Traczyk's avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent d73f960e
......@@ -112,16 +112,16 @@ SET(ringclient_CONTROLLERS
src/RingWindowController.h
src/PreferencesWC.mm
src/PreferencesWC.h
src/AccGeneralVC.mm
src/AccGeneralVC.h
src/AccMediaVC.mm
src/AccMediaVC.h
src/AccRingVC.mm
src/AccRingVC.h
src/AccSipGeneralVC.mm
src/AccSipGeneralVC.h
src/AccAdvancedVC.mm
src/AccAdvancedVC.h
src/AccSecurityVC.mm
src/AccSecurityVC.h
src/AccRingGeneralVC.mm
src/AccRingGeneralVC.h
src/AccAdvancedSipVC.mm
src/AccAdvancedSipVC.h
src/AccAdvancedRingVC.mm
src/AccAdvancedRingVC.h
src/CertificateWC.mm
src/CertificateWC.h
src/BackupAccountWC.mm
......@@ -130,8 +130,6 @@ SET(ringclient_CONTROLLERS
src/RestoreAccountWC.h
src/AudioPrefsVC.mm
src/AudioPrefsVC.h
src/AccountsVC.mm
src/AccountsVC.h
src/VideoPrefsVC.mm
src/VideoPrefsVC.h
src/GeneralPrefsVC.h
......@@ -148,8 +146,6 @@ SET(ringclient_CONTROLLERS
src/LoadingWCDelegate.h
src/AbstractLoadingWC.h
src/AbstractLoadingWC.mm
src/AccDevicesVC.mm
src/AccDevicesVC.h
src/ExportPasswordWC.mm
src/ExportPasswordWC.h
src/MigrateRingAccountsWC.mm
......@@ -179,6 +175,8 @@ SET(ringclient_CONTROLLERS
src/LrcModelsProtocol.h
src/AddSIPAccountVC.mm
src/AddSIPAccountVC.h
src/AccountSettingsVC.mm
src/AccountSettingsVC.h
)
SET(ringclient_BACKENDS
......@@ -222,6 +220,8 @@ SET(ringclient_VIEWS
src/views/SendMessagePanel.mm
src/views/HoverButton.h
src/views/HoverButton.mm
src/views/CenteredClipView.h
src/views/CenteredClipView.mm
)
SET(ringclient_OTHERS
......@@ -247,12 +247,11 @@ SET(ringclient_XIBS
RingWindow
CurrentCall
GeneralPrefs
Accounts
AccGeneral
AccSipGeneral
AccMedia
AccRing
AccAdvanced
AccSecurity
AccRingGeneral
AccAdvancedSip
AccAdvancedRing
AudioPrefs
VideoPrefs
PreferencesWindow
......@@ -265,7 +264,6 @@ SET(ringclient_XIBS
PersonLinker
Broker
Conversation
AccDevices
RingWizardLinkAccount
RingWizardNewAccount
RingWizardChoose
......@@ -279,6 +277,7 @@ SET(ringclient_XIBS
PasswordChange
MessageCells
AddSIPAccountVC
AccountSettings
)
# Icons
......
/*
* Copyright (C) 2016 Savoir-faire Linux Inc.
* Copyright (C) 2015-2018 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -18,9 +19,8 @@
*/
#import <Cocoa/Cocoa.h>
#import <account.h>
@interface AccDevicesVC : NSViewController
#import "AccAdvancedVC.h"
@property Account* account;
@interface AccAdvancedRingVC : AccAdvancedVC <NSTextFieldDelegate>
@end
/*
* Copyright (C) 2015-2018 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import "AccAdvancedRingVC.h"
//LRC
#import <api/lrc.h>
#import <api/newaccountmodel.h>
#import <api/newdevicemodel.h>
@interface AccAdvancedRingVC () {
__unsafe_unretained IBOutlet NSButton *allowIncoming;
__unsafe_unretained IBOutlet NSTextField *nameServerField;
__unsafe_unretained IBOutlet NSTextField *proxyServerField;
__unsafe_unretained IBOutlet NSTextField *bootstrapServerField;
__unsafe_unretained IBOutlet NSButton *enableProxyButton;
}
@end
@implementation AccAdvancedRingVC
//Tags for views
const NSInteger NAME_SERVER_TAG = 100;
const NSInteger PROXY_SERVER_TAG = 200;
const NSInteger BOOTSTRAP_SERVER_TAG = 300;
-(void) updateView {
lrc::api::account::ConfProperties_t accountProperties = self.accountModel->getAccountConfig(self.selectedAccountID);
[allowIncoming setState: accountProperties.allowIncoming];
[nameServerField setStringValue: @(accountProperties.RingNS.uri.c_str())];
[proxyServerField setStringValue:@(accountProperties.proxyServer.c_str())];
[bootstrapServerField setStringValue:@(accountProperties.hostname.c_str())];
[enableProxyButton setState: accountProperties.proxyEnabled];
[proxyServerField setEditable:accountProperties.proxyEnabled];
}
-(void) viewDidLoad {
[super viewDidLoad];
[self updateView];
}
- (void) setSelectedAccount:(std::string) account {
[super setSelectedAccount: account];
[self updateView];
}
#pragma mark - Actions
- (IBAction)allowCallFromUnknownPeer:(id)sender {
lrc::api::account::ConfProperties_t accountProperties = self.accountModel->getAccountConfig(self.selectedAccountID);
if(accountProperties.allowIncoming != [sender state]) {
accountProperties.allowIncoming = [sender state];
self.accountModel->setAccountConfig(self.selectedAccountID, accountProperties);
}
}
- (IBAction)enableProxy:(id)sender {
lrc::api::account::ConfProperties_t accountProperties = self.accountModel->getAccountConfig(self.selectedAccountID);
if(accountProperties.proxyEnabled != [sender state]) {
accountProperties.proxyEnabled = [sender state];
self.accountModel->setAccountConfig(self.selectedAccountID, accountProperties);
}
[proxyServerField setEditable:[sender state]];
}
- (IBAction) valueDidChange: (id) sender
{
lrc::api::account::ConfProperties_t accountProperties = self.accountModel->getAccountConfig(self.selectedAccountID);
switch ([sender tag]) {
case NAME_SERVER_TAG:
if(accountProperties.RingNS.uri != [[sender stringValue] UTF8String]) {
accountProperties.RingNS.uri = [[sender stringValue] UTF8String];
self.accountModel->setAccountConfig(self.selectedAccountID, accountProperties);
}
return;
case PROXY_SERVER_TAG:
if(accountProperties.proxyServer != [[sender stringValue] UTF8String]) {
accountProperties.proxyServer = [[sender stringValue] UTF8String];
self.accountModel->setAccountConfig(self.selectedAccountID, accountProperties);
}
return;
case BOOTSTRAP_SERVER_TAG:
if(accountProperties.hostname != [[sender stringValue] UTF8String]) {
accountProperties.hostname = [[sender stringValue] UTF8String];
self.accountModel->setAccountConfig(self.selectedAccountID, accountProperties);
}
return;
default:
break;
}
[super valueDidChange:sender];
}
#pragma mark - NSTextFieldDelegate methods
-(void)controlTextDidChange:(NSNotification *)notif
{
NSTextField *textField = [notif object];
NSRange test = [[textField currentEditor] selectedRange];
[self valueDidChange:textField];
}
@end
/*
* Copyright (C) 2015-2016 Savoir-faire Linux Inc.
* Copyright (C) 2015-2018 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -19,10 +20,8 @@
#import <Cocoa/Cocoa.h>
#import <account.h>
#import "AccAdvancedVC.h"
@interface AccGeneralVC : NSViewController <NSTextFieldDelegate> {
}
@interface AccAdvancedSipVC : AccAdvancedVC <NSTextFieldDelegate>
@end
This diff is collapsed.
/*
* Copyright (C) 2015-2016 Savoir-faire Linux Inc.
* Copyright (C) 2015-2018 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -19,8 +20,21 @@
#import <Cocoa/Cocoa.h>
#import <account.h>
#import "LrcModelsProtocol.h"
#include <string>
@interface AccAdvancedVC : NSViewController <NSTextFieldDelegate>
@protocol AccountAdvancedProtocol
- (void) setSelectedAccount:(std::string) account;
@end
@interface AccAdvancedVC : NSViewController <NSTableViewDataSource, NSTableViewDelegate, AccountAdvancedProtocol, LrcModelsProtocol>
@property std::string selectedAccountID;
@property (unsafe_unretained) IBOutlet NSButton* selectCACertificateButton;
@property (unsafe_unretained) IBOutlet NSButton* selectUserCertificateButton;
@property (unsafe_unretained) IBOutlet NSButton* selectPrivateKeyButton;
@property (unsafe_unretained) IBOutlet NSSecureTextField *privateKeyPaswordField;
- (IBAction) valueDidChange: (id) sender;
@end
This diff is collapsed.
/*
* Copyright (C) 2016 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import "AccDevicesVC.h"
//Qt
#import <qitemselectionmodel.h>
//LRC
#import <accountmodel.h>
#import <ringdevicemodel.h>
#import <account.h>
#import "QNSTreeController.h"
#import "ExportPasswordWC.h"
@interface AccDevicesVC () <ExportPasswordDelegate>
@property QNSTreeController* devicesTreeController;
@property ExportPasswordWC* passwordWC;
@property (unsafe_unretained) IBOutlet NSOutlineView* deviceDetailsView;
@end
@implementation AccDevicesVC
@synthesize passwordWC;
NSInteger const TAG_NAME = 100;
NSInteger const TAG_DEVICE_IDS = 200;
- (void)awakeFromNib
{
NSLog(@"INIT Devices VC");
QObject::connect(AccountModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
if(!current.isValid())
return;
[self loadAccount];
});
}
- (void)loadAccount
{
auto account = AccountModel::instance().selectedAccount();
self.devicesTreeController = [[QNSTreeController alloc] initWithQModel:(QAbstractItemModel*)account->ringDeviceModel()];
[self.devicesTreeController setAvoidsEmptySelection:NO];
[self.devicesTreeController setChildrenKeyPath:@"children"];
[self.deviceDetailsView bind:@"content" toObject:self.devicesTreeController withKeyPath:@"arrangedObjects" options:nil];
[self.deviceDetailsView bind:@"sortDescriptors" toObject:self.devicesTreeController withKeyPath:@"sortDescriptors" options:nil];
[self.deviceDetailsView bind:@"selectionIndexPaths" toObject:self.devicesTreeController withKeyPath:@"selectionIndexPaths" options:nil];
}
- (IBAction)startExportOnRing:(id)sender
{
NSButton* btbAdd = (NSButton *) sender;
self.account = AccountModel::instance().selectedAccount();
[self showPasswordPrompt];
}
#pragma mark - Export methods
- (void)showPasswordPrompt
{
auto account = AccountModel::instance().selectedAccount();
passwordWC = [[ExportPasswordWC alloc] initWithDelegate:self actionCode:1];
[passwordWC setAccount: account];
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_9
[self.view.window beginSheet:passwordWC.window completionHandler:nil];
#else
[NSApp beginSheet: passwordWC.window
modalForWindow: self.view.window
modalDelegate: self
didEndSelector: nil
contextInfo: nil];
#endif
}
#pragma mark - NSOutlineViewDelegate methods
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item
{
return YES;
}
- (NSTableRowView *)outlineView:(NSOutlineView *)outlineView rowViewForItem:(id)item
{
return [outlineView makeViewWithIdentifier:@"HoverRowView" owner:nil];
}
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
NSTableView* result = [outlineView makeViewWithIdentifier:@"DeviceView" owner:self];
QModelIndex qIdx = [self.devicesTreeController toQIdx:((NSTreeNode*)item)];
if(!qIdx.isValid())
return result;
NSTextField* nameLabel = [result viewWithTag:TAG_NAME];
NSTextField* deviceIDLabel = [result viewWithTag:TAG_DEVICE_IDS];
auto account = AccountModel::instance().selectedAccount();
NSString* string = account->ringDeviceModel()->data(qIdx,Qt::DisplayRole).toString().toNSString();
[nameLabel setStringValue:account->alias().toNSString()];
[deviceIDLabel setStringValue:string];
return result;
}
@end
/*
* Copyright (C) 2015-2016 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import "AccGeneralVC.h"
#import <accountmodel.h>
#import <protocolmodel.h>
#import <qitemselectionmodel.h>
@interface AccGeneralVC () {
__unsafe_unretained IBOutlet NSTextField *aliasTextField;
__unsafe_unretained IBOutlet NSTextField *serverHostTextField;
__unsafe_unretained IBOutlet NSTextField *usernameTextField;
__unsafe_unretained IBOutlet NSSecureTextField *passwordTextField;
NSTextField *clearTextField;
__unsafe_unretained IBOutlet NSButton *upnpButton;
__unsafe_unretained IBOutlet NSButton *autoAnswerButton;
__unsafe_unretained IBOutlet NSButton *userAgentButton;
__unsafe_unretained IBOutlet NSTextField *userAgentTextField;
}
@end
@implementation AccGeneralVC
//Tags for views
typedef NS_ENUM(NSInteger, TagViews) {
ALIAS = 0,
HOSTNAME = 1,
USERNAME = 2,
PASSWORD = 3,
USERAGENT = 4,
DTMF_SIP = 5,
DTMF_RTP = 6,
};
- (void)awakeFromNib
{
NSLog(@"INIT General VC");
[aliasTextField setTag:TagViews::ALIAS];
[serverHostTextField setTag:TagViews::HOSTNAME];
[usernameTextField setTag:TagViews::USERNAME];
[passwordTextField setTag:TagViews::PASSWORD];
[userAgentTextField setTag:TagViews::USERAGENT];
QObject::connect(AccountModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
if(!current.isValid())
return;
[self loadAccount];
});
}
- (IBAction)toggleUpnp:(NSButton *)sender {
AccountModel::instance().selectedAccount()->setUpnpEnabled([sender state] == NSOnState);
}
- (IBAction)toggleAutoAnswer:(NSButton *)sender {
AccountModel::instance().selectedAccount()->setAutoAnswer([sender state] == NSOnState);
}
- (IBAction)toggleCustomAgent:(NSButton *)sender {
[userAgentTextField setEnabled:[sender state] == NSOnState];
AccountModel::instance().selectedAccount()->setHasCustomUserAgent([sender state] == NSOnState);
}
- (void)loadAccount
{
auto account = AccountModel::instance().selectedAccount();
[aliasTextField setStringValue:account->alias().toNSString()];
[serverHostTextField setStringValue:account->hostname().toNSString()];
[usernameTextField setStringValue:account->username().toNSString()];
[passwordTextField setStringValue:account->password().toNSString()];
[clearTextField setStringValue:account->password().toNSString()];
[upnpButton setState:AccountModel::instance().selectedAccount()->isUpnpEnabled()];
[userAgentButton setState:AccountModel::instance().selectedAccount()->hasCustomUserAgent()];
[userAgentTextField setEnabled:AccountModel::instance().selectedAccount()->hasCustomUserAgent()];
[autoAnswerButton setState:AccountModel::instance().selectedAccount()->isAutoAnswer()];
[userAgentTextField setStringValue:account->userAgent().toNSString()];
}
- (IBAction)tryRegistration:(id)sender {
AccountModel::instance().selectedAccount() << Account::EditAction::SAVE;
}
- (IBAction)showPassword:(NSButton *)sender {
if (sender.state == NSOnState) {
clearTextField = [[NSTextField alloc] initWithFrame:passwordTextField.frame];
[clearTextField setTag:passwordTextField.tag];
[clearTextField setDelegate:self];
[clearTextField setBounds:passwordTextField.bounds];
[clearTextField setStringValue:passwordTextField.stringValue];
[clearTextField becomeFirstResponder];
[self.view addSubview:clearTextField];
[passwordTextField setHidden:YES];
} else {
[passwordTextField setStringValue:clearTextField.stringValue];
[passwordTextField setHidden:NO];
[clearTextField removeFromSuperview];
clearTextField = nil;
}
}
/**
* Debug purpose
*/
-(void) dumpFrame:(CGRect) frame WithName:(NSString*) name
{
NSLog(@"frame %@ : %f %f %f %f \n\n",name ,frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
}
#pragma mark - NSTextFieldDelegate methods
- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor
{
return YES;
}
-(void)controlTextDidChange:(NSNotification *)notif
{
NSTextField *textField = [notif object];
switch ([textField tag]) {
case TagViews::ALIAS:
AccountModel::instance().selectedAccount()->setAlias([[textField stringValue] UTF8String]);
AccountModel::instance().selectedAccount()->setDisplayName([[textField stringValue] UTF8String]);
break;
case TagViews::HOSTNAME:
AccountModel::instance().selectedAccount()->setHostname([[textField stringValue] UTF8String]);
break;
case TagViews::USERNAME:
AccountModel::instance().selectedAccount()->setUsername([[textField stringValue] UTF8String]);
break;
case TagViews::PASSWORD:
AccountModel::instance().selectedAccount()->setPassword([[textField stringValue] UTF8String]);
break;
case TagViews::USERAGENT:
AccountModel::instance().selectedAccount()->setUserAgent([[textField stringValue] UTF8String]);
break;
default:
break;
}
}
@end
/*
* Copyright (C) 2015-2016 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import <Cocoa/Cocoa.h>
#import <account.h>
#import "QNSTreeController.h"
@interface AccMediaVC : NSViewController <NSOutlineViewDelegate>
@end
\ No newline at end of file
This diff is collapsed.
/*
* Copyright (C) 2015-2016 Savoir-faire Linux Inc.
* Copyright (C) 2015-2018 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -18,7 +19,16 @@
*/
#import <Cocoa/Cocoa.h>
#import "LrcModelsProtocol.h"
#import "BackupAccountWC.h"
#import "RegisterNameWC.h"
#import "AccountSettingsVC.h"
#import "PasswordChangeWC.h"
@interface AccSecurityVC : NSViewController<NSMenuDelegate, NSPathControlDelegate, NSOpenSavePanelDelegate>
@interface AccRingGeneralVC : NSViewController <NSTextFieldDelegate, LrcModelsProtocol, BackupAccountDelegate, RegisterNameDelegate, AccountGeneralProtocol, NSTableViewDelegate, NSTableViewDataSource, PasswordChangeDelegate>
- (void) setSelectedAccount:(std::string) account;
@property (assign)BOOL accountEnabled;
@end
This diff is collapsed.
/*
* Copyright (C) 2015-2016 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import "AccRingVC.h"
#import <accountmodel.h>
#import <qitemselectionmodel.h>
#import "RegisterNameWC.h"
#import "PasswordChangeWC.h"
@interface AccRingVC () <RegisterNameDelegate>
@property (unsafe_unretained) IBOutlet NSTextField *aliasTextField;
@property (unsafe_unretained) IBOutlet NSTextField *bootstrapField;
@property (unsafe_unretained) IBOutlet NSTextField *blockchainField;
@property (unsafe_unretained) IBOutlet NSTextField *ringIDField;
@property (unsafe_unretained) IBOutlet NSButton *registerBlockchainNameButton;
@property (unsafe_unretained) IBOutlet NSTextField *registeredNameField;
@property (unsafe_unretained) IBOutlet NSButton *upnpButton;
@property (unsafe_unretained) IBOutlet NSButton *autoAnswerButton;
@property (unsafe_unretained) IBOutlet NSButton *userAgentButton;
@property (unsafe_unretained) IBOutlet NSTextField *userAgentTextField;
@property (unsafe_unretained) IBOutlet NSButton *allowUnknown;
@property (unsafe_unretained) IBOutlet NSButton *allowHistory;
@property (unsafe_unretained) IBOutlet NSButton *allowContacts;
@property AbstractLoadingWC* accountModal;
@property PasswordChangeWC* passwordModal;
@end
@implementation AccRingVC
@synthesize bootstrapField;
@synthesize ringIDField;
@synthesize aliasTextField;
@synthesize blockchainField;
@synthesize upnpButton;
@synthesize autoAnswerButton;
@synthesize userAgentButton;
@synthesize userAgentTextField;
@synthesize allowContacts, allowHistory, allowUnknown;
typedef NS_ENUM(NSInteger, TagViews) {
ALIAS = 0,
HOSTNAME,
USERAGENT,
BLOCKCHAIN,
};
- (void)awakeFromNib
{
NSLog(@"INIT Ring VC");
[aliasTextField setTag:TagViews::ALIAS];
[userAgentTextField setTag:TagViews::USERAGENT];
[bootstrapField setTag:TagViews::HOSTNAME];
[blockchainField setTag:TagViews::BLOCKCHAIN];
QObject::connect(AccountModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
if(!current.isValid())
return;
[self loadAccount];
});
}
- (void)loadAccount
{
auto account = AccountModel::instance().selectedAccount();
[self.aliasTextField setStringValue:account->alias().toNSString()];
[allowUnknown setState:account->allowIncomingFromUnknown()];
[allowHistory setState:account->allowIncomingFromHistory()];
[allowContacts setState:account->allowIncomingFromContact()];
[allowHistory setEnabled:!account->allowIncomingFromUnknown()];
[allowContacts setEnabled:!account->allowIncomingFromUnknown()];
[upnpButton setState:account->isUpnpEnabled()];
[userAgentButton setState:account->hasCustomUserAgent()];
[userAgentTextField setEnabled:account->hasCustomUserAgent()];
[autoAnswerButton setState:account->isAutoAnswer()];
[userAgentTextField setStringValue:account->userAgent().toNSString()];
[bootstrapField setStringValue:account->hostname().toNSString()];
[blockchainField setStringValue:account->nameServiceURL().toNSString()];