diff --git a/client/iOS/Controllers/AdvancedBookmarkEditorController.m b/client/iOS/Controllers/AdvancedBookmarkEditorController.m index 17b9750ba..a0357d9e6 100644 --- a/client/iOS/Controllers/AdvancedBookmarkEditorController.m +++ b/client/iOS/Controllers/AdvancedBookmarkEditorController.m @@ -13,6 +13,7 @@ #import "EditorSelectionController.h" #import "ScreenSelectionController.h" #import "PerformanceEditorController.h" +#import "BookmarkGatewaySettingsController.h" @interface AdvancedBookmarkEditorController () @@ -68,7 +69,7 @@ switch (section) { case SECTION_ADVANCED_SETTINGS: // advanced settings - return 7; + return 9; default: break; } @@ -100,23 +101,29 @@ { switch([indexPath row]) { - case 0: // 3G Settings + case 0: // Enable/Disable TSG Settings cellType = TableCellIdentifierYesNo; break; - case 1: // 3G screen/color depth - cellType = TableCellIdentifierSelection; - break; - case 2: // 3G performance settings + case 1: // TS Gateway Settings cellType = TableCellIdentifierSubEditor; break; - case 3: // security mode + case 2: // 3G Settings + cellType = TableCellIdentifierYesNo; + break; + case 3: // 3G screen/color depth cellType = TableCellIdentifierSelection; break; - case 4: // remote program - case 5: // work dir + case 4: // 3G performance settings + cellType = TableCellIdentifierSubEditor; + break; + case 5: // security mode + cellType = TableCellIdentifierSelection; + break; + case 6: // remote program + case 7: // work dir cellType = TableCellIdentifierText; break; - case 6: // console mode + case 8: // console mode cellType = TableCellIdentifierYesNo; break; default: @@ -153,6 +160,24 @@ switch(indexPath.row) { case 0: + { + EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell; + [[flagCell label] setText:NSLocalizedString(@"Enable TS Gateway", @"'Enable TS Gateway': Bookmark enable TSG settings")]; + [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)]; + [[flagCell toggle] setOn:[_params boolForKey:@"enable_tsg_settings"]]; + [[flagCell toggle] addTarget:self action:@selector(toggleSettingValue:) forControlEvents:UIControlEventValueChanged]; + break; + } + case 1: + { + BOOL enable_tsg_settings = [_params boolForKey:@"enable_tsg_settings"]; + EditSubEditTableViewCell* editCell = (EditSubEditTableViewCell*)cell; + [[editCell label] setText:NSLocalizedString(@"TS Gateway Settings", @"'TS Gateway Settings': Bookmark TS Gateway Settings")]; + [[editCell label] setEnabled:enable_tsg_settings]; + [editCell setSelectionStyle:enable_tsg_settings ? UITableViewCellSelectionStyleBlue : UITableViewCellSelectionStyleNone]; + break; + } + case 2: { EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell; [[flagCell label] setText:NSLocalizedString(@"3G Settings", @"'3G Settings': Bookmark enable 3G settings")]; @@ -161,7 +186,7 @@ [[flagCell toggle] addTarget:self action:@selector(toggleSettingValue:) forControlEvents:UIControlEventValueChanged]; break; } - case 1: + case 3: { EditSelectionTableViewCell* selCell = (EditSelectionTableViewCell*)cell; [[selCell label] setText:NSLocalizedString(@"3G Screen", @"'3G Screen': Bookmark 3G Screen settings")]; @@ -172,8 +197,8 @@ [[selCell selection] setEnabled:enable_3G_settings]; [selCell setSelectionStyle:enable_3G_settings ? UITableViewCellSelectionStyleBlue : UITableViewCellSelectionStyleNone]; break; - } - case 2: + } + case 4: { EditSubEditTableViewCell* editCell = (EditSubEditTableViewCell*)cell; [[editCell label] setText:NSLocalizedString(@"3G Performance", @"'3G Performance': Bookmark 3G Performance Settings")]; @@ -181,14 +206,14 @@ [editCell setSelectionStyle:enable_3G_settings ? UITableViewCellSelectionStyleBlue : UITableViewCellSelectionStyleNone]; break; } - case 3: + case 5: { EditSelectionTableViewCell* selCell = (EditSelectionTableViewCell*)cell; [[selCell label] setText:NSLocalizedString(@"Security", @"'Security': Bookmark protocl security settings")]; [[selCell selection] setText:ProtocolSecurityDescription([_params intForKey:@"security"])]; break; } - case 4: + case 6: { EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell; [[textCell label] setText:NSLocalizedString(@"Remote Program", @"'Remote Program': Bookmark remote program settings")]; @@ -198,7 +223,7 @@ [self adjustEditTextTableViewCell:textCell]; break; } - case 5: + case 7: { EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell; [[textCell label] setText:NSLocalizedString(@"Working Directory", @"'Working Directory': Bookmark working directory settings")]; @@ -208,7 +233,7 @@ [self adjustEditTextTableViewCell:textCell]; break; } - case 6: + case 8: { EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell; [[flagCell label] setText:NSLocalizedString(@"Console Mode", @"'Console Mode': Bookmark console mode settings")]; @@ -233,14 +258,18 @@ switch ([indexPath row]) { case 1: + if ([_params boolForKey:@"enable_tsg_settings"]) + viewCtrl = [[[BookmarkGatewaySettingsController alloc] initWithBookmark:_bookmark] autorelease]; + break; + case 3: if ([_params boolForKey:@"enable_3g_settings"]) viewCtrl = [[[ScreenSelectionController alloc] initWithConnectionParams:_params keyPath:@"settings_3g"] autorelease]; break; - case 2: + case 4: if ([_params boolForKey:@"enable_3g_settings"]) viewCtrl = [[[PerformanceEditorController alloc] initWithConnectionParams:_params keyPath:@"settings_3g"] autorelease]; break; - case 3: + case 5: viewCtrl = [[[EditorSelectionController alloc] initWithConnectionParams:_params entries:[NSArray arrayWithObject:@"security"] selections:[NSArray arrayWithObject:SelectionForSecuritySetting()]] autorelease]; break; default: @@ -267,13 +296,13 @@ switch(textField.tag) { // update remote program/work dir settings - case GET_TAG(SECTION_ADVANCED_SETTINGS, 4): + case GET_TAG(SECTION_ADVANCED_SETTINGS, 6): { [_params setValue:[textField text] forKey:@"remote_program"]; break; } - case GET_TAG(SECTION_ADVANCED_SETTINGS, 5): + case GET_TAG(SECTION_ADVANCED_SETTINGS, 7): { [_params setValue:[textField text] forKey:@"working_dir"]; break; @@ -293,12 +322,22 @@ switch(valueSwitch.tag) { case GET_TAG(SECTION_ADVANCED_SETTINGS, 0): - [_params setBool:[valueSwitch isOn] forKey:@"enable_3g_settings"]; + { + [_params setBool:[valueSwitch isOn] forKey:@"enable_tsg_settings"]; NSArray* indexPaths = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:1 inSection:SECTION_ADVANCED_SETTINGS], [NSIndexPath indexPathForRow:2 inSection:SECTION_ADVANCED_SETTINGS], nil]; [[self tableView] reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone]; break; + } + + case GET_TAG(SECTION_ADVANCED_SETTINGS, 2): + { + [_params setBool:[valueSwitch isOn] forKey:@"enable_3g_settings"]; + NSArray* indexPaths = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:3 inSection:SECTION_ADVANCED_SETTINGS], [NSIndexPath indexPathForRow:2 inSection:SECTION_ADVANCED_SETTINGS], nil]; + [[self tableView] reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone]; + break; + } - case GET_TAG(SECTION_ADVANCED_SETTINGS, 6): + case GET_TAG(SECTION_ADVANCED_SETTINGS, 8): [_params setBool:[valueSwitch isOn] forKey:@"console"]; break; diff --git a/client/iOS/Controllers/BookmarkGatewaySettingsController.h b/client/iOS/Controllers/BookmarkGatewaySettingsController.h index 9a5d02d25..e2c8d5c01 100644 --- a/client/iOS/Controllers/BookmarkGatewaySettingsController.h +++ b/client/iOS/Controllers/BookmarkGatewaySettingsController.h @@ -1,13 +1,25 @@ -// -// BookmarkGatewaySettingsController.h -// FreeRDP -// -// Created by Thinstuff Developer on 4/30/13. -// -// +/* + Controller to edit ts gateway bookmark settings + + Copyright 2013 Thinstuff Technologies GmbH, Author: Martin Fleisz + + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ -#import +#import "EditorBaseController.h" -@interface BookmarkGatewaySettingsController : UITableViewController +@class ComputerBookmark; +@class ConnectionParams; + +@interface BookmarkGatewaySettingsController : EditorBaseController +{ +@private + ComputerBookmark* _bookmark; + ConnectionParams* _params; +} + +// init for the given bookmark +- (id)initWithBookmark:(ComputerBookmark*)bookmark; @end diff --git a/client/iOS/Controllers/BookmarkGatewaySettingsController.m b/client/iOS/Controllers/BookmarkGatewaySettingsController.m index ef9463add..586ead7c2 100644 --- a/client/iOS/Controllers/BookmarkGatewaySettingsController.m +++ b/client/iOS/Controllers/BookmarkGatewaySettingsController.m @@ -7,6 +7,12 @@ // #import "BookmarkGatewaySettingsController.h" +#import "Bookmark.h" +#import "Utils.h" +#import "EditorSelectionController.h" + +#define SECTION_TSGATEWAY_SETTINGS 0 +#define SECTION_COUNT 1 @interface BookmarkGatewaySettingsController () @@ -14,11 +20,13 @@ @implementation BookmarkGatewaySettingsController -- (id)initWithStyle:(UITableViewStyle)style +- (id)initWithBookmark:(ComputerBookmark*)bookmark { - self = [super initWithStyle:style]; - if (self) { - // Custom initialization + if ((self = [super initWithStyle:UITableViewStyleGrouped])) + { + // set additional settings state according to bookmark data + _bookmark = [bookmark retain]; + _params = [bookmark params]; } return self; } @@ -26,97 +34,203 @@ - (void)viewDidLoad { [super viewDidLoad]; - - // Uncomment the following line to preserve selection between presentations. - // self.clearsSelectionOnViewWillAppear = NO; - - // Uncomment the following line to display an Edit button in the navigation bar for this view controller. - // self.navigationItem.rightBarButtonItem = self.editButtonItem; + [self setTitle:NSLocalizedString(@"TS Gateway Settings", @"TS Gateway Settings title")]; } -- (void)didReceiveMemoryWarning +- (void)viewWillAppear:(BOOL)animated { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. + [super viewWillAppear:animated]; + + // we need to reload the table view data here to have up-to-date data for the + // advanced settings accessory items (like for resolution/color mode settings) + [[self tableView] reloadData]; +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +{ + return YES; +} + +- (void)dealloc +{ + [super dealloc]; + [_bookmark release]; } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { -#warning Potentially incomplete method implementation. // Return the number of sections. - return 0; + return SECTION_COUNT; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { -#warning Incomplete method implementation. // Return the number of rows in the section. + switch (section) + { + case SECTION_TSGATEWAY_SETTINGS: // ts gateway settings + return 5; + default: + break; + } + return 0; } +// set section headers +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section +{ + switch(section) + { + case SECTION_TSGATEWAY_SETTINGS: + return NSLocalizedString(@"TS Gateway", @"'TS Gateway': ts gateway settings header"); + } + return @"unknown"; +} + - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - static NSString *CellIdentifier = @"Cell"; - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; + // determine the required cell type + NSString* cellType = nil; + switch([indexPath section]) + { + case SECTION_TSGATEWAY_SETTINGS: // advanced settings + { + switch([indexPath row]) + { + case 0: // hostname + case 1: // port + case 2: // username + case 4: // domain + cellType = TableCellIdentifierText; + break; + case 3: // password + cellType = TableCellIdentifierSecretText; + break; + default: + break; + } + break; + } + } + NSAssert(cellType != nil, @"Couldn't determine cell type"); + + // get the table view cell + UITableViewCell *cell = [self tableViewCellFromIdentifier:cellType]; + NSAssert(cell, @"Invalid cell"); - // Configure the cell... + // set cell values + switch([indexPath section]) + { + // advanced settings + case SECTION_TSGATEWAY_SETTINGS: + [self initGatewaySettings:indexPath cell:cell]; + break; + + default: + break; + } return cell; } -/* -// Override to support conditional editing of the table view. -- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath +// updates server settings in the UI +- (void)initGatewaySettings:(NSIndexPath*)indexPath cell:(UITableViewCell*)cell { - // Return NO if you do not want the specified item to be editable. - return YES; + EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell; + [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)]; + switch([indexPath row]) + { + case 0: + { + [[textCell label] setText:NSLocalizedString(@"Host", @"'Host': Bookmark hostname")]; + [[textCell textfield] setText:[_params StringForKey:@"tsg_hostname"]]; + [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")]; + break; + } + case 1: + { + int port = [_params intForKey:@"tsg_port"]; + if (port == 0) port = 443; + [[textCell label] setText:NSLocalizedString(@"Port", @"'Port': Bookmark port")]; + [[textCell textfield] setText:[NSString stringWithFormat:@"%d", port]]; + [[textCell textfield] setKeyboardType:UIKeyboardTypeNumberPad]; + break; + } + case 2: + { + [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)]; + [[textCell label] setText:NSLocalizedString(@"Username", @"'Username': Bookmark username")]; + [[textCell textfield] setText:[_params StringForKey:@"tsg_username"]]; + [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")]; + break; + } + case 3: + { + [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)]; + [[textCell label] setText:NSLocalizedString(@"Password", @"'Password': Bookmark password")]; + [[textCell textfield] setText:[_params StringForKey:@"tsg_password"]]; + [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")]; + break; + } + case 4: + { + [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)]; + [[textCell label] setText:NSLocalizedString(@"Domain", @"'Domain': Bookmark domain")]; + [[textCell textfield] setText:[_params StringForKey:@"tsg_domain"]]; + [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")]; + break; + } + default: + NSLog(@"Invalid row index in settings table!"); + break; + } + + [self adjustEditTextTableViewCell:textCell]; } -*/ -/* -// Override to support editing the table view. -- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath + +#pragma mark - +#pragma mark Text Field delegate + +- (BOOL)textFieldShouldReturn:(UITextField*)textField { - if (editingStyle == UITableViewCellEditingStyleDelete) { - // Delete the row from the data source - [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; - } - else if (editingStyle == UITableViewCellEditingStyleInsert) { - // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view - } + [textField resignFirstResponder]; + return NO; } -*/ -/* -// Override to support rearranging the table view. -- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath +- (BOOL)textFieldShouldEndEditing:(UITextField *)textField { + switch(textField.tag) + { + // update server settings + case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 0): + [_params setValue:[textField text] forKey:@"tsg_hostname"]; + break; + + case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 1): + [_params setInt:[[textField text] intValue] forKey:@"tsg_port"]; + break; + + case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 2): + [_params setValue:[textField text] forKey:@"tsg_username"]; + break; + + case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 3): + [_params setValue:[textField text] forKey:@"tsg_password"]; + break; + + case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 4): + [_params setValue:[textField text] forKey:@"tsg_domain"]; + break; + + default: + break; + } + return YES; } -*/ -/* -// Override to support conditional rearranging of the table view. -- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath -{ - // Return NO if you do not want the item to be re-orderable. - return YES; -} -*/ - -#pragma mark - Table view delegate - -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath -{ - // Navigation logic may go here. Create and push another view controller. - /* - <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; - // ... - // Pass the selected object to the new view controller. - [self.navigationController pushViewController:detailViewController animated:YES]; - [detailViewController release]; - */ -} @end diff --git a/client/iOS/Controllers/CredentialsEditorController.m b/client/iOS/Controllers/CredentialsEditorController.m index 21e328ad5..a029ad3b6 100644 --- a/client/iOS/Controllers/CredentialsEditorController.m +++ b/client/iOS/Controllers/CredentialsEditorController.m @@ -56,6 +56,12 @@ return YES; } +- (void)dealloc +{ + [super dealloc]; + [_bookmark release]; +} + #pragma mark - #pragma mark Table view data source diff --git a/client/iOS/Controllers/PerformanceEditorController.m b/client/iOS/Controllers/PerformanceEditorController.m index 104b13c13..2e1d4e0eb 100644 --- a/client/iOS/Controllers/PerformanceEditorController.m +++ b/client/iOS/Controllers/PerformanceEditorController.m @@ -56,6 +56,12 @@ return key; } +- (void)dealloc +{ + [super dealloc]; + [_params release]; +} + #pragma mark - #pragma mark Table view data source diff --git a/client/iOS/Defaults.plist b/client/iOS/Defaults.plist index a60e3be19..801082384 100644 --- a/client/iOS/Defaults.plist +++ b/client/iOS/Defaults.plist @@ -65,6 +65,18 @@ console + enable_tsg_settings + + tsg_hostname + + tsg_port + 443 + tsg_username + + tsg_password + + tsg_domain + ui.auto_scroll_touchpointer diff --git a/client/iOS/Models/RDPSession.m b/client/iOS/Models/RDPSession.m index 6144637d1..d43f27959 100644 --- a/client/iOS/Models/RDPSession.m +++ b/client/iOS/Models/RDPSession.m @@ -164,6 +164,18 @@ NSString* TSXSessionDidFailToConnectNotification = @"TSXSessionDidFailToConnect" break; } + // ts gateway settings + if ([_params boolForKey:@"enable_tsg_settings"]) + { + settings->GatewayHostname = strdup([_params UTF8StringForKey:@"tsg_hostname"]); + settings->GatewayPort = [_params intForKey:@"tsg_port"]; + settings->GatewayUsername = strdup([_params UTF8StringForKey:@"tsg_username"]); + settings->GatewayPassword = strdup([_params UTF8StringForKey:@"tsg_password"]); + settings->GatewayDomain = strdup([_params UTF8StringForKey:@"tsg_domain"]); + settings->GatewayUsageMethod = TRUE; + settings->GatewayUseSameCredentials = FALSE; + } + // Remote keyboard layout settings->KeyboardLayout = 0x409; diff --git a/libfreerdp/core/gateway/tsg.h b/libfreerdp/core/gateway/tsg.h index 40ba028a1..23b10155b 100644 --- a/libfreerdp/core/gateway/tsg.h +++ b/libfreerdp/core/gateway/tsg.h @@ -61,8 +61,8 @@ struct rdp_tsg LPWSTR MachineName; TSG_STATE state; BOOL PendingPdu; - BOOL BytesRead; - BOOL BytesAvailable; + UINT32 BytesRead; + UINT32 BytesAvailable; UINT32 StubOffset; UINT32 StubLength; rdpSettings* settings;