Commit 4de68ce8 authored by Alexandre Lision's avatar Alexandre Lision Committed by Guillaume Roguez

security: add options for SIP accounts

This commits adds ability to enable TLS and SRTP
in SIP accounts preferences.

Refs #73027
Change-Id: Idad3d1cd3c325fa370855af79b50b2da19a87832
parent 8131541e
......@@ -56,6 +56,8 @@ SET(ringclient_CONTROLLERS
src/AccAdvancedVC.h
src/AccSecurityVC.mm
src/AccSecurityVC.h
src/CertificateWC.mm
src/CertificateWC.h
src/AudioPrefsVC.mm
src/AudioPrefsVC.h
src/AccountsVC.mm
......@@ -103,7 +105,8 @@ SET(ringclient_XIBS
AudioPrefs
VideoPrefs
PreferencesScreen
RingWizard)
RingWizard
CertificateWindow)
# Icons
# This part tells CMake where to find and install the file itself
......
......@@ -137,22 +137,6 @@
#pragma mark - NSTextFieldDelegate methods
- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor
{
NSLog(@"textShouldBeginEditing");
return YES;
}
- (void)control:(NSControl *)control didFailToValidatePartialString:(NSString *)string errorDescription:(NSString *)error
{
NSLog(@"didFailToValidatePartialString");
}
-(void)controlTextDidBeginEditing:(NSNotification *)obj
{
}
-(void)controlTextDidChange:(NSNotification *)notif
{
NSTextField *textField = [notif object];
......
......@@ -54,6 +54,8 @@
@property (assign) IBOutlet NSTextField *serverHostTextField;
@property (assign) IBOutlet NSTextField *usernameTextField;
@property (assign) IBOutlet NSSecureTextField *passwordTextField;
@property (assign) IBOutlet NSTextField *clearTextField;
@property (assign) IBOutlet NSButton *tryRegisterButton;
@property (assign) IBOutlet NSButton *upnpButton;
@property (assign) IBOutlet NSButton *autoAnswerButton;
......@@ -72,6 +74,7 @@
@synthesize serverHostTextField;
@synthesize usernameTextField;
@synthesize passwordTextField;
@synthesize clearTextField;
@synthesize upnpButton;
@synthesize autoAnswerButton;
@synthesize userAgentButton;
......@@ -124,6 +127,7 @@
[self.serverHostTextField setStringValue:account->hostname().toNSString()];
[self.usernameTextField setStringValue:account->username().toNSString()];
[self.passwordTextField setStringValue:account->password().toNSString()];
[self.clearTextField setStringValue:account->password().toNSString()];
}
switch (account->protocol()) {
......@@ -148,6 +152,36 @@
[self.userAgentTextField setStringValue:account->userAgent().toNSString()];
}
- (IBAction)tryRegistration:(id)sender {
self.privateAccount << 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];
[boxingParameters 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
......
......@@ -34,7 +34,7 @@
#import <account.h>
@interface AccSecurityVC : NSViewController<NSPathControlDelegate, NSOpenSavePanelDelegate> {
@interface AccSecurityVC : NSViewController<NSMenuDelegate, NSPathControlDelegate, NSOpenSavePanelDelegate> {
}
......
This diff is collapsed.
......@@ -113,12 +113,9 @@ public:
[accountsListView bind:@"sortDescriptors" toObject:treeController withKeyPath:@"sortDescriptors" options:nil];
[accountsListView bind:@"selectionIndexPaths" toObject:treeController withKeyPath:@"selectionIndexPaths" options:nil];
QObject::connect(AccountModel::instance(),
&QAbstractItemModel::dataChanged,
[=](const QModelIndex &topLeft, const QModelIndex &bottomRight) {
NSLog(@"data changed %d, %d", topLeft.row(), bottomRight.row());
[accountsListView reloadDataForRowIndexes:
[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(topLeft.row(), bottomRight.row() + 1)]
columnIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, accountsListView.tableColumns.count)]];
......@@ -208,8 +205,8 @@ public:
[configPanels insertTabViewItem:generalTabItem atIndex:0];
[configPanels insertTabViewItem:audioTabItem atIndex:1];
[configPanels insertTabViewItem:videoTabItem atIndex:2];
//[configPanels insertTabViewItem:advancedTabItem atIndex:3];
//[configPanels insertTabViewItem:securityTabItem atIndex:4];
[configPanels insertTabViewItem:advancedTabItem atIndex:3];
[configPanels insertTabViewItem:securityTabItem atIndex:4];
[self.generalVC loadAccount:acc];
[self.audioVC loadAccount:acc];
......@@ -270,6 +267,7 @@ public:
Account* toToggle = AccountModel::instance()->getAccountByModelIndex(accIdx);
NSButtonCell *cell = [col dataCellForRow:row];
toToggle->setEnabled(cell.state == NSOnState ? NO : YES);
toToggle << Account::EditAction::SAVE;
}
}
......@@ -288,7 +286,17 @@ public:
// -------------------------------------------------------------------------------
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
NSCell *returnCell = [tableColumn dataCell];
NSCell *returnCell;
QModelIndex qIdx = [treeController toQIdx:((NSTreeNode*)item)];
// Prevent user from enabling/disabling IP2IP account
if ([[tableColumn identifier] isEqualToString:COLUMNID_ENABLE] &&
AccountModel::instance()->ip2ip()->index() == qIdx) {
returnCell = [[NSCell alloc] init];
} else {
returnCell = [tableColumn dataCell];
}
return returnCell;
}
......@@ -331,25 +339,30 @@ public:
{
cell.title = AccountModel::instance()->data(qIdx, Qt::DisplayRole).toString().toNSString();
} else if([[tableColumn identifier] isEqualToString:COLUMNID_STATE]) {
Account::RegistrationState state = qvariant_cast<Account::RegistrationState>(AccountModel::instance()->data(qIdx, (int)Account::Role::RegistrationState));
NSTextFieldCell* stateCell = cell;
Account::RegistrationState state = qvariant_cast<Account::RegistrationState>(qIdx.data((int)Account::Role::RegistrationState));
switch (state) {
case Account::RegistrationState::READY:
[cell setTitle:@"Ready"];
[stateCell setTextColor:[NSColor colorWithCalibratedRed:116/255.0 green:179/255.0 blue:93/255.0 alpha:1.0]];
[stateCell setTitle:@"Ready"];
break;
case Account::RegistrationState::TRYING:
[cell setTitle:@"Trying..."];
[stateCell setTextColor:[NSColor redColor]];
[stateCell setTitle:@"Trying..."];
break;
case Account::RegistrationState::UNREGISTERED:
[cell setTitle:@"Unregistered"];
[stateCell setTextColor:[NSColor blackColor]];
[stateCell setTitle:@"Unregistered"];
break;
case Account::RegistrationState::ERROR:
[cell setTitle:@"Error"];
[stateCell setTextColor:[NSColor redColor]];
[stateCell setTitle:@"Error"];
break;
default:
break;
}
} else if([[tableColumn identifier] isEqualToString:COLUMNID_ENABLE]) {
[cell setState:AccountModel::instance()->data(qIdx, Qt::CheckStateRole).value<BOOL>()];
[cell setState:qIdx.data(Qt::CheckStateRole).value<BOOL>()];
}
}
......@@ -396,7 +409,7 @@ public:
{
QModelIndex proxyIdx = proxyProtocolModel->index(index, 0);
QModelIndex qIdx = AccountModel::instance()->protocolModel()->index(proxyProtocolModel->mapToSource(proxyIdx).row());
[item setTitle:AccountModel::instance()->protocolModel()->data(qIdx, Qt::DisplayRole).toString().toNSString()];
[item setTitle:qIdx.data(Qt::DisplayRole).toString().toNSString()];
return YES;
}
......
......@@ -73,6 +73,8 @@
if([[Audio::Settings::instance()->recordPath().toNSURL() absoluteString] isEqualToString:@""]) {
NSArray * pathComponentArray = [self pathComponentArray];
[recordingsPathControl setPathComponentCells:pathComponentArray];
} else {
[recordingsPathControl setURL:Audio::Settings::instance()->recordPath().toNSURL()];
}
}
......
//
// CertificateWC.h
// Ring
//
// Created by Alexandre Lision on 2015-04-28.
//
//
#import <Cocoa/Cocoa.h>
#import <certificate.h>
@interface CertificateWC : NSWindowController
- (void) setCertificate:(Certificate*) cert;
@end
//
// CertificateWC.m
// Ring
//
// Created by Alexandre Lision on 2015-04-28.
//
//
#import "CertificateWC.h"
@implementation CertificateWC
- (void)windowDidLoad {
[super windowDidLoad];
}
- (void) setCertificate:(Certificate*) cert
{
NSLog(@"CertificateWC loaded");
}
- (IBAction)closePanel:(id)sender
{
[NSApp endSheet:self.window];
[self.window orderOut:self];
}
@end
......@@ -35,18 +35,21 @@
@interface GeneralPrefsVC ()
@property (assign) IBOutlet NSTextField *historyChangedLabel;
@property (assign) IBOutlet NSView *advancedGeneralSettings;
@end
@implementation GeneralPrefsVC {
}
@implementation GeneralPrefsVC
@synthesize historyChangedLabel;
@synthesize advancedGeneralSettings;
- (void)loadView
{
[super loadView];
[[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:Preferences::HistoryLimit options:NSKeyValueObservingOptionNew context:NULL];
[[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:Preferences::ShowAdvanced options:NSKeyValueObservingOptionNew context:NULL];
[advancedGeneralSettings setHidden:![[NSUserDefaults standardUserDefaults] boolForKey:Preferences::ShowAdvanced]];
}
- (IBAction)clearHistory:(id)sender {
......@@ -58,8 +61,11 @@
-(void)observeValueForKeyPath:(NSString *)aKeyPath ofObject:(id)anObject
change:(NSDictionary *)aChange context:(void *)aContext
{
NSLog(@"VALUE CHANGED");
[historyChangedLabel setHidden:NO];
if (aKeyPath == Preferences::HistoryLimit) {
[historyChangedLabel setHidden:NO];
} else if (aKeyPath == Preferences::ShowAdvanced) {
[advancedGeneralSettings setHidden:[[aChange objectForKey: NSKeyValueChangeNewKey] boolValue]];
}
}
@end
......@@ -34,13 +34,13 @@
@interface PreferencesVC : NSViewController <NSToolbarDelegate>
- (void) close;
@property (nonatomic, assign) NSViewController *currentVC;
@property (nonatomic, assign) NSViewController *accountsPrefsVC;
@property (nonatomic, assign) NSViewController *generalPrefsVC;
@property (nonatomic, assign) NSViewController *audioPrefsVC;
@property (nonatomic, assign) NSViewController *videoPrefsVC;
- (void) close;
- (void)displayGeneral:(NSToolbarItem *)sender;
- (void)displayAudio:(NSToolbarItem *)sender;
- (void)displayAncrage:(NSToolbarItem *)sender;
......
......@@ -202,7 +202,6 @@ static NSString* const kCallButtonIdentifer = @"CallButtonIdentifier";
- (IBAction)placeCall:(id)sender
{
Call* c = CallModel::instance()->dialingCall();
// check for a valid ring hash
NSCharacterSet *hexSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789abcdefABCDEF"];
BOOL valid = [[[callField stringValue] stringByTrimmingCharactersInSet:hexSet] isEqualToString:@""];
......
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="AccGeneralVC">
......@@ -147,6 +146,26 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="SEc-jZ-TUE">
<rect key="frame" x="327" y="5" width="129" height="18"/>
<buttonCell key="cell" type="check" title="Show password" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="Ue3-ai-FBV">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="showPassword:" target="-2" id="5zI-is-yfV"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jgg-ZS-LyJ">
<rect key="frame" x="323" y="37" width="137" height="32"/>
<buttonCell key="cell" type="push" title="Try Registration" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="j6w-ZG-17T">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="tryRegistration:" target="-2" id="KIF-Ps-esl"/>
</connections>
</button>
</subviews>
</customView>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7NY-Hh-Icd">
......
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6751" systemVersion="13F1077" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6751"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="AccVideoVC">
......@@ -30,7 +29,7 @@
</connections>
</button>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qN4-Se-Waf">
<rect key="frame" x="33" y="55" width="322" height="216"/>
<rect key="frame" x="33" y="55" width="379" height="245"/>
<subviews>
<scrollView focusRingType="none" fixedFrame="YES" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0Xq-Du-JwG">
<rect key="frame" x="0.0" y="46" width="315" height="170"/>
......@@ -140,16 +139,16 @@
<action selector="moveUp:" target="-2" id="y2e-P5-leK"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="flI-L9-J7Q">
<rect key="frame" x="3" y="224" width="53" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Codecs" id="DlW-RF-2xv">
<font key="font" metaFont="systemBold"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</customView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="flI-L9-J7Q">
<rect key="frame" x="31" y="279" width="53" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Codecs" id="DlW-RF-2xv">
<font key="font" metaFont="systemBold"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<point key="canvasLocation" x="273" y="167"/>
</customView>
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6751" systemVersion="14C1510" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6751" systemVersion="13F1077" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6751"/>
</dependencies>
......@@ -72,17 +72,6 @@
<action selector="chooseOutput:" target="-2" id="SIh-kG-rV5"/>
</connections>
</popUpButton>
<pathControl verticalHuggingPriority="750" fixedFrame="YES" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nyE-tZ-v4C">
<rect key="frame" x="95" y="316" width="210" height="26"/>
<pathCell key="cell" selectable="YES" editable="YES" alignment="left" pathStyle="popUp" id="SPB-Bz-vDM">
<font key="font" metaFont="system"/>
<url key="url" string="file://localhost/Applications/"/>
</pathCell>
<connections>
<action selector="pathControlSingleClick:" target="-2" id="a8r-s5-lxq"/>
<outlet property="delegate" destination="-2" id="JXx-Le-f5R"/>
</connections>
</pathControl>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bMB-Zm-k0Z">
<rect key="frame" x="20" y="253" width="99" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Audio devices" id="B0r-wh-wc3">
......@@ -132,6 +121,17 @@
<action selector="chooseInput:" target="-2" id="ADO-Qj-tAz"/>
</connections>
</popUpButton>
<pathControl verticalHuggingPriority="750" fixedFrame="YES" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nyE-tZ-v4C">
<rect key="frame" x="95" y="318" width="210" height="26"/>
<pathCell key="cell" selectable="YES" editable="YES" alignment="left" pathStyle="popUp" id="SPB-Bz-vDM">
<font key="font" metaFont="system"/>
<url key="url" string="file://localhost/Applications/"/>
</pathCell>
<connections>
<action selector="pathControlSingleClick:" target="-2" id="jyC-qZ-OzW"/>
<outlet property="delegate" destination="-2" id="JXx-Le-f5R"/>
</connections>
</pathControl>
</subviews>
</customView>
</subviews>
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment