Commit f5fc479f authored by Alexandre Lision's avatar Alexandre Lision

ui: add account screen management

    - ability to create SIP/IAX/RING accounts
    - add configuration panels: security panel needs to be discussed
    - some settings may change

    Refs #67077

Change-Id: I17afbcbbd067bf75f381492997ad40a72703cf0f
parent 8521baaf
This diff is collapsed.
/*
* Copyright (C) 2004-2015 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.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#import <Cocoa/Cocoa.h>
#include <account.h>
@interface AccAdvancedVC : NSViewController <NSTextFieldDelegate> {
}
- (void)loadAccount:(Account *)account;
@end
/*
* Copyright (C) 2004-2015 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.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#define REGISTRATION_TAG 0
#define LOCALPORT_TAG 1
#define STUNURL_TAG 2
#define PUBLICADDR_TAG 3
#define PUBLICPORT_TAG 4
#define MINAUDIO_TAG 5
#define MAXAUDIO_TAG 6
#define MINVIDEO_TAG 7
#define MAXVIDEO_TAG 8
#import "AccAdvancedVC.h"
@interface AccAdvancedVC ()
@property Account* privateAccount;
@property (assign) IBOutlet NSTextField *registrationField;
@property (assign) IBOutlet NSTextField *localPortField;
@property (assign) IBOutlet NSButton *isUsingSTUN;
@property (assign) IBOutlet NSTextField *STUNserverURLField;
@property (assign) IBOutlet NSTextField *minAudioRTPRange;
@property (assign) IBOutlet NSTextField *maxAudioRTPRange;
@property (assign) IBOutlet NSTextField *minVideoRTPRange;
@property (assign) IBOutlet NSTextField *maxVideoRTPRange;
@property (assign) IBOutlet NSStepper *registrationStepper;
@property (assign) IBOutlet NSStepper *localPortStepper;
@property (assign) IBOutlet NSStepper *minAudioPortStepper;
@property (assign) IBOutlet NSStepper *maxAudioPortStepper;
@property (assign) IBOutlet NSStepper *minVideoPortStepper;
@property (assign) IBOutlet NSStepper *maxVideoPortStepper;
@property (assign) IBOutlet NSMatrix *publishAddrAndPortRadioGroup;
@property (assign) IBOutlet NSTextField *publishedAddrField;
@property (assign) IBOutlet NSTextField *publishedPortField;
@end
@implementation AccAdvancedVC
@synthesize privateAccount;
@synthesize registrationField;
@synthesize localPortField;
@synthesize isUsingSTUN;
@synthesize STUNserverURLField;
@synthesize minAudioRTPRange;
@synthesize maxAudioRTPRange;
@synthesize minVideoRTPRange;
@synthesize maxVideoRTPRange;
@synthesize registrationStepper;
@synthesize localPortStepper;
@synthesize minAudioPortStepper;
@synthesize maxAudioPortStepper;
@synthesize minVideoPortStepper;
@synthesize maxVideoPortStepper;
@synthesize publishAddrAndPortRadioGroup;
@synthesize publishedAddrField;
@synthesize publishedPortField;
- (void)awakeFromNib
{
NSLog(@"INIT Advanced VC");
[registrationStepper setTag:REGISTRATION_TAG];
[localPortStepper setTag:LOCALPORT_TAG];
[minAudioPortStepper setTag:MINAUDIO_TAG];
[maxAudioPortStepper setTag:MAXAUDIO_TAG];
[minVideoPortStepper setTag:MINVIDEO_TAG];
[maxVideoPortStepper setTag:MAXVIDEO_TAG];
[registrationField setTag:REGISTRATION_TAG];
[localPortField setTag:LOCALPORT_TAG];
[minAudioRTPRange setTag:MINAUDIO_TAG];
[maxAudioRTPRange setTag:MAXAUDIO_TAG];
[minVideoRTPRange setTag:MINVIDEO_TAG];
[maxVideoRTPRange setTag:MAXVIDEO_TAG];
[STUNserverURLField setTag:STUNURL_TAG];
[publishedPortField setTag:PUBLICPORT_TAG];
[publishedAddrField setTag:PUBLICADDR_TAG];
}
- (void)loadAccount:(Account *)account
{
privateAccount = account;
[self updateControlsWithTag:REGISTRATION_TAG];
[self updateControlsWithTag:LOCALPORT_TAG];
[self updateControlsWithTag:MINAUDIO_TAG];
[self updateControlsWithTag:MAXAUDIO_TAG];
[self updateControlsWithTag:MINVIDEO_TAG];
[self updateControlsWithTag:MAXVIDEO_TAG];
[STUNserverURLField setStringValue:privateAccount->sipStunServer().toNSString()];
[isUsingSTUN setState:privateAccount->isSipStunEnabled()?NSOnState:NSOffState];
[STUNserverURLField setEnabled:privateAccount->isSipStunEnabled()];
if(privateAccount->isPublishedSameAsLocal())
[publishAddrAndPortRadioGroup selectCellAtRow:0 column:0];
else {
[publishAddrAndPortRadioGroup selectCellAtRow:1 column:0];
}
[publishedAddrField setStringValue:privateAccount->publishedAddress().toNSString()];
[publishedPortField setIntValue:privateAccount->publishedPort()];
[publishedAddrField setEnabled:!privateAccount->isPublishedSameAsLocal()];
[publishedPortField setEnabled:!privateAccount->isPublishedSameAsLocal()];
}
#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];
NSRange test = [[textField currentEditor] selectedRange];
[self valueDidChange:textField];
//FIXME: saving account lose focus because in NSTreeController we remove and reinsert row so View selction change
[textField.window makeFirstResponder:textField];
[[textField currentEditor] setSelectedRange:test];
}
- (IBAction) valueDidChange: (id) sender
{
switch ([sender tag]) {
case REGISTRATION_TAG:
privateAccount->setRegistrationExpire([sender integerValue]);
break;
case LOCALPORT_TAG:
privateAccount->setLocalPort([sender integerValue]);
break;
case STUNURL_TAG:
privateAccount->setSipStunServer([[sender stringValue] UTF8String]);
break;
case PUBLICADDR_TAG:
privateAccount->setPublishedAddress([[sender stringValue] UTF8String]);
break;
case PUBLICPORT_TAG:
privateAccount->setPublishedPort([sender integerValue]);
break;
case MINAUDIO_TAG:
privateAccount->setAudioPortMin([sender integerValue]);
break;
case MAXAUDIO_TAG:
privateAccount->setAudioPortMax([sender integerValue]);
break;
case MINVIDEO_TAG:
privateAccount->setVideoPortMin([sender integerValue]);
break;
case MAXVIDEO_TAG:
privateAccount->setVideoPortMax([sender integerValue]);
break;
default:
break;
}
[self updateControlsWithTag:[sender tag]];
}
- (IBAction)toggleSTUN:(NSButton *)sender
{
privateAccount->setSipStunEnabled([sender state]==NSOnState);
[STUNserverURLField setEnabled:privateAccount->isSipStunEnabled()];
}
- (IBAction)didSwitchPublishedAddress:(NSMatrix *)matrix
{
NSInteger row = [matrix selectedRow];
if(row == 0) {
privateAccount->setPublishedSameAsLocal(YES);
} else {
privateAccount->setPublishedSameAsLocal(NO);
}
[publishedAddrField setEnabled:!privateAccount->isPublishedSameAsLocal()];
[publishedPortField setEnabled:!privateAccount->isPublishedSameAsLocal()];
}
- (void) updateControlsWithTag:(NSInteger) tag
{
switch (tag) {
case REGISTRATION_TAG:
[registrationStepper setIntegerValue:privateAccount->registrationExpire()];
[registrationField setIntegerValue:privateAccount->registrationExpire()];
break;
case LOCALPORT_TAG:
[localPortStepper setIntegerValue:privateAccount->localPort()];
[localPortField setIntegerValue:privateAccount->localPort()];
break;
case MINAUDIO_TAG:
[minAudioPortStepper setIntegerValue:privateAccount->audioPortMin()];
[minAudioRTPRange setIntegerValue:privateAccount->audioPortMin()];
break;
case MAXAUDIO_TAG:
[maxAudioPortStepper setIntegerValue:privateAccount->audioPortMax()];
[maxAudioRTPRange setIntegerValue:privateAccount->audioPortMax()];
break;
case MINVIDEO_TAG:
[minVideoPortStepper setIntegerValue:privateAccount->videoPortMin()];
[minVideoRTPRange setIntegerValue:privateAccount->videoPortMin()];
break;
case MAXVIDEO_TAG:
[maxVideoPortStepper setIntegerValue:privateAccount->videoPortMax()];
[maxVideoRTPRange setIntegerValue:privateAccount->videoPortMax()];
break;
default:
break;
}
}
@end
This diff is collapsed.
/*
* Copyright (C) 2004-2015 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.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef ACCAUDIOVC_H
#define ACCAUDIOVC_H
#import <Cocoa/Cocoa.h>
#include <account.h>
#import "QNSTreeController.h"
@interface AccAudioVC : NSViewController <NSOutlineViewDelegate, NSPathControlDelegate> {
}
- (void)loadAccount:(Account *)account;
@end
#endif // ACCAUDIOVC_H
\ No newline at end of file
/*
* Copyright (C) 2004-2015 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.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#define COLUMNID_STATE @"AudioStateColumn"
#define COLUMNID_CODECS @"AudioCodecsColumn"
#define COLUMNID_FREQ @"AudioFrequencyColumn"
#define COLUMNID_BITRATE @"AudioBitrateColumn"
#import "AccAudioVC.h"
#include <QSortFilterProxyModel>
#include <audio/codecmodel.h>
#include <accountmodel.h>
@interface AccAudioVC ()
@property Account* privateAccount;
@property QNSTreeController *treeController;
@property (assign) IBOutlet NSOutlineView *codecsView;
@end
@implementation AccAudioVC
@synthesize treeController;
@synthesize codecsView;
@synthesize privateAccount;
- (void)awakeFromNib
{
NSLog(@"INIT Audio VC");
}
- (void)loadAccount:(Account *)account
{
privateAccount = account;
treeController = [[QNSTreeController alloc] initWithQModel:privateAccount->codecModel()->audioCodecs()];
[treeController setAvoidsEmptySelection:NO];
[treeController setChildrenKeyPath:@"children"];
[codecsView bind:@"content" toObject:treeController withKeyPath:@"arrangedObjects" options:nil];
[codecsView bind:@"sortDescriptors" toObject:treeController withKeyPath:@"sortDescriptors" options:nil];
[codecsView bind:@"selectionIndexPaths" toObject:treeController withKeyPath:@"selectionIndexPaths" options:nil];
}
- (IBAction)moveUp:(id)sender {
}
- (IBAction)moveDown:(id)sender {
}
- (IBAction)toggleCodec:(NSOutlineView*)sender {
NSInteger row = [sender clickedRow];
NSTableColumn *col = [sender tableColumnWithIdentifier:COLUMNID_STATE];
NSButtonCell *cell = [col dataCellForRow:row];
QModelIndex qIdx = privateAccount->codecModel()->audioCodecs()->index(row, 0, QModelIndex());
privateAccount->codecModel()->audioCodecs()->setData(
qIdx, cell.state == NSOnState ? Qt::Unchecked : Qt::Checked, Qt::CheckStateRole);
}
#pragma mark - NSOutlineViewDelegate methods
// -------------------------------------------------------------------------------
// shouldSelectItem:item
// -------------------------------------------------------------------------------
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item;
{
return YES;
}
// -------------------------------------------------------------------------------
// dataCellForTableColumn:tableColumn:item
// -------------------------------------------------------------------------------
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
NSCell *returnCell = [tableColumn dataCell];
if(item == nil)
return returnCell;
return returnCell;
}
// -------------------------------------------------------------------------------
// textShouldEndEditing:fieldEditor
// -------------------------------------------------------------------------------
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
{
if ([[fieldEditor string] length] == 0)
{
// don't allow empty node names
return NO;
}
else
{
return YES;
}
}
// -------------------------------------------------------------------------------
// shouldEditTableColumn:tableColumn:item
//
// Decide to allow the edit of the given outline view "item".
// -------------------------------------------------------------------------------
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
return NO;
}
// -------------------------------------------------------------------------------
// outlineView:willDisplayCell:forTableColumn:item
// -------------------------------------------------------------------------------
- (void)outlineView:(NSOutlineView *)olv willDisplayCell:(NSCell*)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
QModelIndex qIdx = [treeController toQIdx:((NSTreeNode*)item)];
if(!qIdx.isValid())
return;
if([[tableColumn identifier] isEqualToString:COLUMNID_STATE]) {
[cell setState:privateAccount->codecModel()->audioCodecs()->data(qIdx, Qt::CheckStateRole).value<BOOL>()?NSOnState:NSOffState];
} else if ([[tableColumn identifier] isEqualToString:COLUMNID_CODECS])
{
cell.title = privateAccount->codecModel()->audioCodecs()->data(qIdx, CodecModel::Role::NAME).toString().toNSString();
} else if ([[tableColumn identifier] isEqualToString:COLUMNID_FREQ])
{
cell.title = privateAccount->codecModel()->audioCodecs()->data(qIdx, CodecModel::Role::SAMPLERATE).toString().toNSString();
} else if ([[tableColumn identifier] isEqualToString:COLUMNID_BITRATE])
{
cell.title = privateAccount->codecModel()->audioCodecs()->data(qIdx, CodecModel::Role::BITRATE).toString().toNSString();
}
}
// -------------------------------------------------------------------------------
// outlineViewSelectionDidChange:notification
// -------------------------------------------------------------------------------
- (void)outlineViewSelectionDidChange:(NSNotification *)notification
{
}
@end
This diff is collapsed.
/*
* Copyright (C) 2004-2015 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.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef ACCGENERALVC_H
#define ACCGENERALVC_H
#import <Cocoa/Cocoa.h>
#include <account.h>
@interface AccGeneralVC : NSViewController <NSTextFieldDelegate> {
}
- (IBAction)toggleUpnp:(NSButton *)sender;
- (IBAction)toggleAutoAnswer:(NSButton *)sender;
- (IBAction)toggleCustomAgent:(NSButton *)sender;
- (void)loadAccount:(Account *)account;
@end
#endif // ACCGENERALVC_H
\ No newline at end of file
/*
* Copyright (C) 2004-2015 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.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#define ALIAS_TAG 0
#define HOSTNAME_TAG 1
#define USERNAME_TAG 2
#define PASSWORD_TAG 3
#define USERAGENT_TAG 4
#import "AccGeneralVC.h"
#include <accountmodel.h>
#import <protocolmodel.h>
#include <qitemselectionmodel.h>
@interface AccGeneralVC ()
@property Account* privateAccount;
@property (assign) IBOutlet NSView *boxingAccount;
@property (assign) IBOutlet NSView *boxingParameters;
@property (assign) IBOutlet NSView *boxingCommon;
@property (assign) IBOutlet NSTextField *aliasTextField;
@property (assign) IBOutlet NSTextField *typeLabel;
@property (assign) IBOutlet NSTextField *serverHostTextField;
@property (assign) IBOutlet NSTextField *usernameTextField;
@property (assign) IBOutlet NSSecureTextField *passwordTextField;
@property (assign) IBOutlet NSButton *upnpButton;
@property (assign) IBOutlet NSButton *autoAnswerButton;
@property (assign) IBOutlet NSButton *userAgentButton;
@property (assign) IBOutlet NSTextField *userAgentTextField;
@end
@implementation AccGeneralVC
@synthesize typeLabel;
@synthesize boxingAccount;
@synthesize boxingParameters;
@synthesize boxingCommon;
@synthesize aliasTextField;
@synthesize serverHostTextField;
@synthesize usernameTextField;
@synthesize passwordTextField;
@synthesize upnpButton;
@synthesize autoAnswerButton;
@synthesize userAgentButton;
@synthesize userAgentTextField;
@synthesize privateAccount;
- (void)awakeFromNib
{
NSLog(@"INIT General VC");
[aliasTextField setTag:ALIAS_TAG];
[serverHostTextField setTag:HOSTNAME_TAG];
[usernameTextField setTag:USERNAME_TAG];
[passwordTextField setTag:PASSWORD_TAG];
[userAgentTextField setTag:USERAGENT_TAG];
}
- (IBAction)toggleUpnp:(NSButton *)sender {
privateAccount->setUpnpEnabled([sender state] == NSOnState);
}
- (IBAction)toggleAutoAnswer:(NSButton *)sender {
privateAccount->setAutoAnswer([sender state] == NSOnState);
}
- (IBAction)toggleCustomAgent:(NSButton *)sender {
[self.userAgentTextField setEnabled:[sender state] == NSOnState];
privateAccount->setHasCustomUserAgent([sender state] == NSOnState);
}
- (void)loadAccount:(Account *)account
{
privateAccount = account;
if([account->alias().toNSString() isEqualToString:@"IP2IP"]) {
[boxingAccount.subviews setValue:@YES forKeyPath:@"hidden"];
[boxingParameters.subviews setValue:@YES forKeyPath:@"hidden"];
NSLog(@"IP@IP");
// Put visible items at top of the frame
[boxingCommon setFrameOrigin:NSMakePoint(boxingAccount.frame.origin.x,
boxingAccount.frame.origin.y - 40)];
[boxingCommon setNeedsDisplay:YES];
} else {
[boxingAccount.subviews setValue:@NO forKeyPath:@"hidden"];
[boxingParameters.subviews setValue:@NO forKeyPath:@"hidden"];
[self.aliasTextField setStringValue:account->alias().toNSString()];
[self.serverHostTextField setStringValue:account->hostname().toNSString()];
[self.usernameTextField setStringValue:account->username().toNSString()];
[self.passwordTextField setStringValue:account->password().toNSString()];
}
switch (account->protocol()) {
case Account::Protocol::SIP:
[self.typeLabel setStringValue:@"SIP"];
break;
case Account::Protocol::IAX:
[self.typeLabel setStringValue:@"IAX"];
break;
case Account::Protocol::RING:
[self.typeLabel setStringValue:@"RING"];
break;
default:
break;
}
[upnpButton setState:privateAccount->isUpnpEnabled()];
[userAgentButton setState:privateAccount->hasCustomUserAgent()];
[userAgentTextField setEnabled:privateAccount->hasCustomUserAgent()];
[self.autoAnswerButton setState:privateAccount->isAutoAnswer()];
[self.userAgentTextField setStringValue:account->userAgent().toNSString()];
}
#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 ALIAS_TAG:
privateAccount->setAlias([[textField stringValue] UTF8String]);
break;
case HOSTNAME_TAG:
privateAccount->setHostname([[textField stringValue] UTF8String]);
break;
case USERNAME_TAG:
privateAccount->setUsername([[textField stringValue] UTF8String]);
break;
case PASSWORD_TAG:
privateAccount->setPassword([[textField stringValue] UTF8String]);
break;
case USERAGENT_TAG:
privateAccount->setUserAgent([[textField stringValue] UTF8String]);
break;
default:
break;
}
}
@end
This diff is collapsed.
/*
* Copyright (C) 2004-2015 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.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.