Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added support for webroot and https - this is for reverse proxy setups
  • Loading branch information
zipleen committed Jun 3, 2013
1 parent ae5b716 commit b1880c3
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 148 deletions.
4 changes: 3 additions & 1 deletion TvhClient/TVHSettings.h
Expand Up @@ -24,6 +24,8 @@
#define TVHS_PORT_KEY @"ServerPort"
#define TVHS_USERNAME_KEY @"Username"
#define TVHS_PASSWORD_KEY @"Password"
#define TVHS_USE_HTTPS @"ServerUseHTTPS"
#define TVHS_SERVER_WEBROOT @"ServerWebroot"
#define TVHS_SSH_PF_HOST @"SSHPF_Host"
#define TVHS_SSH_PF_PORT @"SSHPF_Port"
#define TVHS_SSH_PF_USERNAME @"SSHPF_Username"
Expand All @@ -33,7 +35,7 @@
#define TVHS_SERVERS @"Servers"
#define TVHS_SORT_CHANNEL @"SortChannelBy"

#define TVHS_SERVER_KEYS @[TVHS_SERVER_NAME, TVHS_IP_KEY, TVHS_PORT_KEY, TVHS_USERNAME_KEY, TVHS_PASSWORD_KEY, TVHS_SSH_PF_HOST, TVHS_SSH_PF_PORT, TVHS_SSH_PF_USERNAME, TVHS_SSH_PF_PASSWORD]
#define TVHS_SERVER_KEYS @[TVHS_SERVER_NAME, TVHS_IP_KEY, TVHS_PORT_KEY, TVHS_USERNAME_KEY, TVHS_PASSWORD_KEY, TVHS_USE_HTTPS, TVHS_SERVER_WEBROOT, TVHS_SSH_PF_HOST, TVHS_SSH_PF_PORT, TVHS_SSH_PF_USERNAME, TVHS_SSH_PF_PASSWORD]
#define TVHS_SORT_CHANNEL_BY_NAME 0
#define TVHS_SORT_CHANNEL_BY_NUMBER 1

Expand Down
16 changes: 13 additions & 3 deletions TvhClient/TVHSettings.m
Expand Up @@ -186,6 +186,8 @@ - (NSDictionary*)newServer {
TVHS_PORT_KEY:@"9981",
TVHS_USERNAME_KEY:@"",
TVHS_PASSWORD_KEY:@"",
TVHS_USE_HTTPS:@"",
TVHS_SERVER_WEBROOT:@"",
TVHS_SSH_PF_HOST:@"",
TVHS_SSH_PF_PORT:@"",
TVHS_SSH_PF_USERNAME:@"",
Expand Down Expand Up @@ -252,8 +254,7 @@ - (void)removeServer:(NSInteger)serverId {
#pragma mark Properties

- (NSURL*)baseURL {
NSString *ip;
NSString *port;
NSString *ip, *port, *useHttps, *webroot;
if( !_baseURL ) {
if ( self.selectedServer == NSNotFound ) {
return nil;
Expand All @@ -269,8 +270,17 @@ - (NSURL*)baseURL {
port = @"9981";
}
}
// crude hack instead of a bool, but this way I don't have to deal with different NSArray objects
useHttps = [self currentServerProperty:TVHS_USE_HTTPS];
if ( ! ([useHttps isEqualToString:@""] || [useHttps isEqualToString:@"s"]) ) {
useHttps = @"";
}
webroot = [self currentServerProperty:TVHS_SERVER_WEBROOT];
if ( ! webroot ) {
webroot = @"";
}

NSString *baseUrlString = [NSString stringWithFormat:@"http://%@:%@", ip, port];
NSString *baseUrlString = [NSString stringWithFormat:@"http%@://%@:%@%@", useHttps, ip, port, webroot];
NSURL *url = [NSURL URLWithString:baseUrlString];
_baseURL = url;
}
Expand Down
64 changes: 52 additions & 12 deletions TvhClient/TVHSettingsServersViewController.m
Expand Up @@ -55,14 +55,17 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte
return NSLocalizedString(@"Authentication", @"..in Settings server edit");
}
if (section == 2) {
return NSLocalizedString(@"Advanced Options", @"..in Settings server edit");
}
if (section == 3) {
return NSLocalizedString(@"SSH Port Forward", @"..in Settings server edit");
}
return nil;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
Expand All @@ -74,18 +77,24 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
return 2;
}
if ( section == 2 ) {
return 2;
}
if ( section == 3 ) {
return 4;
}
return 0;
}

- (NSInteger)indexOfSettingsArray:(NSInteger)section row:(NSInteger)row {
NSInteger c = 0;
if ( section == 1 ) {
if ( section >= 1 ) {
c = c + 3;
}
if ( section == 2 ) {
c = c + 3 + 2;
if ( section >= 2 ) {
c = c + 2;
}
if ( section >= 3 ) {
c = c + 2;
}
return c + row;
}
Expand All @@ -101,17 +110,20 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
//UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(136, 10, 160, 30)];
UITextField *textField = (UITextField *)[cell viewWithTag:201];
UILabel *textLabel = (UILabel *)[cell viewWithTag:200];
UISwitch *switchfield = (UISwitch *)[cell viewWithTag:202];
textField.adjustsFontSizeToFitWidth = YES;
textField.textColor = [UIColor blackColor];
textField.secureTextEntry = NO;
textField.returnKeyType = UIReturnKeyDone;
textField.hidden = NO;
switchfield.hidden = YES;
if ( indexPath.row == 0 && indexPath.section == 0 ) {
textLabel.text = NSLocalizedString(@"Name", @"..in Settings server edit");
textField.placeholder = @"";
}
if ( indexPath.row == 1 && indexPath.section == 0 ) {
textLabel.text = NSLocalizedString(@"Server Address", @"..in Settings server edit");
textField.placeholder = @"";
textLabel.text = NSLocalizedString(@"Address", @"..in Settings server edit");
textField.placeholder = @"IP or Address";
textField.keyboardType = UIKeyboardTypeAlphabet;
}
if ( indexPath.row == 2 && indexPath.section == 0 ) {
Expand All @@ -130,22 +142,38 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
textField.keyboardType = UIKeyboardTypeDefault;
textField.secureTextEntry = YES;
}
if ( indexPath.row == 0 && indexPath.section == 2 ) {
textLabel.text = NSLocalizedString(@"Server Address", @"..in Settings server edit");
textField.placeholder = @"";
if ( indexPath.row == 0 && indexPath.section == 2 ) {
textLabel.text = NSLocalizedString(@"Use HTTPS", @"..in Settings server edit");
textField.hidden = YES;
switchfield.hidden = NO;
if ( [[self.server objectForKey:TVHS_USE_HTTPS] isEqualToString:@""] ) {
[switchfield setOn:NO];
} else {
[switchfield setOn:YES];
}
[switchfield addTarget:self action: @selector(setUseHttps:) forControlEvents:UIControlEventValueChanged];
}
if ( indexPath.row == 1 && indexPath.section == 2 ) {
textLabel.text = NSLocalizedString(@"Web Root", @"..in Settings server edit");
textField.placeholder = @"/";
textField.keyboardType = UIKeyboardTypeURL;
}
if ( indexPath.row == 0 && indexPath.section == 3 ) {
textLabel.text = NSLocalizedString(@"Address", @"..in Settings server edit");
textField.placeholder = @"SSH Host Address";
textField.keyboardType = UIKeyboardTypeAlphabet;
}
if ( indexPath.row == 1 && indexPath.section == 2 ) {
if ( indexPath.row == 1 && indexPath.section == 3 ) {
textLabel.text = NSLocalizedString(@"SSH Port", @"..in Settings server edit");
textField.placeholder = @"22";
textField.keyboardType = UIKeyboardTypeNumberPad;
}
if ( indexPath.row == 2 && indexPath.section == 2 ) {
if ( indexPath.row == 2 && indexPath.section == 3 ) {
textLabel.text = NSLocalizedString(@"SSH Username", @"..in Settings server edit");
textField.placeholder = @"";
textField.keyboardType = UIKeyboardTypeAlphabet;
}
if ( indexPath.row == 3 && indexPath.section == 2 ) {
if ( indexPath.row == 3 && indexPath.section == 3 ) {
textLabel.text = NSLocalizedString(@"SSH Password", @"..in Settings server edit");
textField.placeholder = @"";
textField.keyboardType = UIKeyboardTypeAlphabet;
Expand All @@ -166,6 +194,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ( indexPath.row == 0 && indexPath.section == 2 ) {
return;
}

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UITextField *textField = (UITextField *)[cell viewWithTag:201];
[textField becomeFirstResponder];
Expand Down Expand Up @@ -199,4 +231,12 @@ - (IBAction)saveServer:(id)sender {
}
[self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)setUseHttps:(UISwitch*)sender {
if ( sender.on ) {
[self.server setObject:@"s" forKey:TVHS_USE_HTTPS];
} else {
[self.server setObject:@"" forKey:TVHS_USE_HTTPS];
}
}
@end
136 changes: 4 additions & 132 deletions TvhClient/en.lproj/MainStoryboard_iPhone.storyboard
Expand Up @@ -243,6 +243,10 @@
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocorrectionType="no"/>
</textField>
<switch opaque="NO" tag="202" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" id="npb-Zv-4Fd">
<rect key="frame" x="203" y="9" width="79" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</switch>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
Expand Down Expand Up @@ -1687,138 +1691,6 @@
<image name="satellite.png" width="16" height="16"/>
<image name="status.png" width="30" height="30"/>
</resources>
<classes>
<class className="SDSegmentedControl" superclassName="UISegmentedControl">
<source key="sourceIdentifier" type="project" relativePath="./Classes/SDSegmentedControl.h"/>
</class>
<class className="TVHAutoRecDetailViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TVHAutoRecDetailViewController.h"/>
<relationships>
<relationship kind="action" name="saveButton:"/>
<relationship kind="outlet" name="itemChannel" candidateClass="UITableViewCell"/>
<relationship kind="outlet" name="itemComment" candidateClass="UITextField"/>
<relationship kind="outlet" name="itemCreatedBy" candidateClass="UITextField"/>
<relationship kind="outlet" name="itemDvrConfig" candidateClass="UITableViewCell"/>
<relationship kind="outlet" name="itemEnable" candidateClass="UISwitch"/>
<relationship kind="outlet" name="itemGenre" candidateClass="UITableViewCell"/>
<relationship kind="outlet" name="itemPriority" candidateClass="UITableViewCell"/>
<relationship kind="outlet" name="itemStartAround" candidateClass="UITableViewCell"/>
<relationship kind="outlet" name="itemTag" candidateClass="UITableViewCell"/>
<relationship kind="outlet" name="itemTitle" candidateClass="UITextField"/>
<relationship kind="outlet" name="itemWeekdays" candidateClass="UITableViewCell"/>
</relationships>
</class>
<class className="TVHChannelStoreProgramsViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TVHChannelStoreProgramsViewController.h"/>
<relationships>
<relationship kind="action" name="playStream:"/>
<relationship kind="action" name="segmentDidChange:"/>
<relationship kind="outlet" name="segmentedControl" candidateClass="SDSegmentedControl"/>
<relationship kind="outlet" name="tableView" candidateClass="UITableView"/>
</relationships>
</class>
<class className="TVHChannelStoreViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TVHChannelStoreViewController.h"/>
</class>
<class className="TVHDebugLogViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TVHDebugLogViewController.h"/>
<relationships>
<relationship kind="action" name="clearLog:"/>
<relationship kind="action" name="debugButton:" candidateClass="UIBarButtonItem"/>
<relationship kind="action" name="moveSplit:"/>
<relationship kind="outlet" name="debugButton" candidateClass="UIBarButtonItem"/>
<relationship kind="outlet" name="searchBar" candidateClass="UISearchBar"/>
</relationships>
</class>
<class className="TVHEpgTableViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TVHEpgTableViewController.h"/>
<relationships>
<relationship kind="action" name="filterSegmentedControlClicked:" candidateClass="UISegmentedControl"/>
<relationship kind="action" name="showHideSegmentedBar:" candidateClass="UIBarButtonItem"/>
<relationship kind="outlet" name="filterSegmentedControl" candidateClass="UISegmentedControl"/>
<relationship kind="outlet" name="filterToolBar" candidateClass="UIToolbar"/>
<relationship kind="outlet" name="searchBar" candidateClass="UISearchBar"/>
<relationship kind="outlet" name="tableView" candidateClass="UITableView"/>
</relationships>
</class>
<class className="TVHProgramDetailViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TVHProgramDetailViewController.h"/>
<relationships>
<relationship kind="action" name="addAutoRecordToTVHeadend:"/>
<relationship kind="action" name="addRecordMoreItemsToTVHeadend:"/>
<relationship kind="action" name="playStream:"/>
<relationship kind="action" name="segmentedDidChange:"/>
<relationship kind="outlet" name="channelTitle" candidateClass="UILabel"/>
<relationship kind="outlet" name="programImage" candidateClass="UIImageView"/>
<relationship kind="outlet" name="programTitle" candidateClass="UILabel"/>
<relationship kind="outlet" name="record" candidateClass="UIButton"/>
<relationship kind="outlet" name="segmentedControl" candidateClass="SDSegmentedControl"/>
<relationship kind="outlet" name="tableView" candidateClass="UITableView"/>
</relationships>
</class>
<class className="TVHRecordingsDetailViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TVHRecordingsDetailViewController.h"/>
<relationships>
<relationship kind="action" name="playStream:"/>
<relationship kind="action" name="removeRecording:"/>
<relationship kind="action" name="segmentedDidChange:"/>
<relationship kind="outlet" name="channelTitle" candidateClass="UILabel"/>
<relationship kind="outlet" name="programImage" candidateClass="UIImageView"/>
<relationship kind="outlet" name="programTitle" candidateClass="UILabel"/>
<relationship kind="outlet" name="record" candidateClass="UIButton"/>
<relationship kind="outlet" name="segmentedControl" candidateClass="SDSegmentedControl"/>
<relationship kind="outlet" name="tableView" candidateClass="UITableView"/>
</relationships>
</class>
<class className="TVHRecordingsViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TVHRecordingsViewController.h"/>
<relationships>
<relationship kind="action" name="segmentedDidChange:"/>
<relationship kind="outlet" name="segmentedControl" candidateClass="SDSegmentedControl"/>
<relationship kind="outlet" name="tableView" candidateClass="UITableView"/>
</relationships>
</class>
<class className="TVHSettingsGenericFieldViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TVHSettingsGenericFieldViewController.h"/>
</class>
<class className="TVHSettingsGenericTextViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TVHSettingsGenericTextViewController.h"/>
<relationships>
<relationship kind="outlet" name="genericText" candidateClass="UITextView"/>
</relationships>
</class>
<class className="TVHSettingsServersViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TVHSettingsServersViewController.h"/>
<relationships>
<relationship kind="action" name="saveServer:"/>
</relationships>
</class>
<class className="TVHSettingsViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TVHSettingsViewController.h"/>
<relationships>
<relationship kind="action" name="doneSettings:"/>
</relationships>
</class>
<class className="TVHStatusSubscriptionsViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TVHStatusSubscriptionsViewController.h"/>
<relationships>
<relationship kind="action" name="switchPolling:"/>
<relationship kind="outlet" name="switchButton" candidateClass="UIBarButtonItem"/>
</relationships>
</class>
<class className="TVHTagStoreViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TVHTagStoreViewController.h"/>
<relationships>
<relationship kind="outlet" name="settingsButton" candidateClass="UIBarButtonItem"/>
</relationships>
</class>
<class className="TVHUICustomNavigationBar" superclassName="UINavigationBar">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TVHUICustomNavigationBar.h"/>
</class>
<class className="TVHUICustomTabBar" superclassName="UITabBar">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TVHUICustomTabBar.h"/>
</class>
</classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
Expand Down

0 comments on commit b1880c3

Please sign in to comment.