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
<?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">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="AccAudioVC">
<connections>
<outlet property="codecsView" destination="qUo-eR-iuq" id="gyu-3z-rNc"/>
<outlet property="view" destination="c22-O7-iKe" id="PBG-fI-bZm"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="c22-O7-iKe">
<rect key="frame" x="0.0" y="0.0" width="525" height="356"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<scrollView focusRingType="none" fixedFrame="YES" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yLX-W9-gcE">
<rect key="frame" x="32" y="122" width="317" height="189"/>
<clipView key="contentView" misplaced="YES" id="ttA-YT-HQA">
<rect key="frame" x="1" y="17" width="238" height="117"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<outlineView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" autosaveColumns="NO" headerView="WuO-RU-Dfb" indentationPerLevel="16" outlineTableColumn="PGV-RF-f13" id="qUo-eR-iuq">
<rect key="frame" x="0.0" y="0.0" width="315" height="19"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn identifier="AudioStateColumn" width="49.3828125" minWidth="10" maxWidth="3.4028234663852886e+38" id="txE-JZ-54H">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Enabled">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<buttonCell key="dataCell" type="check" bezelStyle="regularSquare" imagePosition="overlaps" inset="2" id="9bj-Tu-ggx">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
<connections>
<action selector="toggleCodec:" target="-2" id="huW-3m-PQc"/>
</connections>
</buttonCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
<tableColumn identifier="AudioCodecsColumn" width="116" minWidth="40" maxWidth="1000" id="PGV-RF-f13">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Codecs">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" title="Text" id="RBO-p6-Wej">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
<tableColumn identifier="AudioFrequencyColumn" width="64" minWidth="10" maxWidth="3.4028234663852886e+38" id="hjc-hd-CQe">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Frequency">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="PYp-JZ-g1v">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
<tableColumn identifier="AudioBitrateColumn" width="73.5" minWidth="10" maxWidth="3.4028234663852886e+38" id="sd4-Co-8hS">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Bitrate">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="bZK-L6-HSm">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
</tableColumns>
<connections>
<outlet property="delegate" destination="-2" id="PfI-dp-hKo"/>
</connections>
</outlineView>
</subviews>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="tAn-XY-KM0">
<rect key="frame" x="1" y="119" width="223" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="e9m-eK-gwP">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="WuO-RU-Dfb">
<rect key="frame" x="0.0" y="0.0" width="238" height="17"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="zaU-3l-OYA">
<rect key="frame" x="26" y="89" width="58" height="32"/>
<buttonCell key="cell" type="push" title="Up" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="MbZ-7X-K5I">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="moveUp:" target="-2" id="3SD-Po-WZK"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qs3-sN-wPV">
<rect key="frame" x="18" y="319" width="53" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Codecs" id="biN-bX-qM1">
<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>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ipf-oU-a70">
<rect key="frame" x="18" y="63" width="72" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Ringtones" id="aMg-uJ-Krx">
<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>
<pathControl hidden="YES" verticalHuggingPriority="750" fixedFrame="YES" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="8cX-0X-us7">
<rect key="frame" x="161" y="25" width="207" height="26"/>
<pathCell key="cell" selectable="YES" editable="YES" alignment="left" pathStyle="popUp" id="SGo-Cl-DoP">
<font key="font" metaFont="system"/>
<url key="url" string="file://localhost/Applications/"/>
<allowedTypes>
<string>public.folder</string>
</allowedTypes>
</pathCell>
<connections>
<outlet property="delegate" destination="-2" id="X9a-9D-s9f"/>
</connections>
</pathControl>
<button hidden="YES" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Hmk-UR-N3c">
<rect key="frame" x="30" y="29" width="128" height="18"/>
<buttonCell key="cell" type="check" title="Enable ringtones" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="KkI-i1-mfY">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xN7-EP-314">
<rect key="frame" x="77" y="89" width="76" height="32"/>
<buttonCell key="cell" type="push" title="Down" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Bbz-hd-1CE">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="moveDown:" target="-2" id="mQQ-dj-CAq"/>
</connections>
</button>
</subviews>
<point key="canvasLocation" x="139.5" y="52"/>
</customView>
</objects>
</document>
/*
* 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);
}