Reworked the wizard views to handle remote provisioning more correctly: we now have a specialized view for it

This commit is contained in:
Guillaume BIENKOWSKI 2014-04-02 16:58:13 +02:00
parent 08d486afa5
commit f5d03d7af0
3 changed files with 152 additions and 18 deletions

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="5053" systemVersion="13C64" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment defaultVersion="1536" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
</dependencies>
<objects>
@ -14,7 +15,10 @@
<outlet property="createAccountView" destination="44" id="70"/>
<outlet property="externalAccountButton" destination="39" id="133"/>
<outlet property="externalAccountView" destination="56" id="72"/>
<outlet property="remoteParamsLabel" destination="bBb-47-pCq" id="aSA-QL-JR7"/>
<outlet property="provisionedAccountView" destination="xVK-hL-6pe" id="jZM-mc-m1Q"/>
<outlet property="provisionedDomain" destination="wRB-Sh-K8J" id="Ieb-x8-yL4"/>
<outlet property="provisionedPassword" destination="ClH-fT-a8N" id="h61-p1-4qG"/>
<outlet property="provisionedUsername" destination="MyR-eX-QTa" id="gmr-FI-hpH"/>
<outlet property="remoteProvisioningButton" destination="Kbn-dL-C5h" id="PPk-DJ-nEb"/>
<outlet property="validateAccountView" destination="101" id="112"/>
<outlet property="welcomeView" destination="21" id="28"/>
@ -362,8 +366,80 @@
<action selector="onSignInExternalClick:" destination="-1" eventType="touchUpInside" id="115"/>
</connections>
</button>
<label hidden="YES" opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="These parameters were retrieved from a remote provisioning profile." textAlignment="center" lineBreakMode="wordWrap" numberOfLines="7" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="bBb-47-pCq" userLabel="remoteParamsLabel">
<rect key="frame" x="34" y="269" width="254" height="53"/>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<view contentMode="scaleToFill" id="xVK-hL-6pe" userLabel="provisionedAccountView">
<rect key="frame" x="0.0" y="0.0" width="320" height="394"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Provisioned account" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="YKJ-nv-RUT" userLabel="title">
<rect key="frame" x="31" y="34" width="258" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Account setup assistant"/>
<fontDescription key="fontDescription" type="italicSystem" pointSize="20"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
<color key="shadowColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<size key="shadowOffset" width="-1" height="-1"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="200" contentMode="left" text="Enter your username and password" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="10" adjustsFontSizeToFit="NO" id="pU9-SC-9uY" userLabel="label">
<rect key="frame" x="40" y="82" width="240" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" tag="104" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Username" adjustsFontSizeToFit="NO" minimumFontSize="10" background="field_background.png" id="MyR-eX-QTa" userLabel="usernameField" customClass="UILinphoneTextField">
<rect key="frame" x="33" y="140" width="255" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Username"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocorrectionType="no"/>
<connections>
<outlet property="delegate" destination="-1" id="hkA-6W-28S"/>
</connections>
</textField>
<textField opaque="NO" clipsSubviews="YES" tag="105" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Password" adjustsFontSizeToFit="NO" minimumFontSize="10" background="field_background.png" id="ClH-fT-a8N" userLabel="passwordField" customClass="UILinphoneTextField">
<rect key="frame" x="33" y="185" width="255" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Password"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" secureTextEntry="YES"/>
<connections>
<outlet property="delegate" destination="-1" id="lRN-EH-mjp"/>
</connections>
</textField>
<textField opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="106" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Domain" adjustsFontSizeToFit="NO" minimumFontSize="10" background="field_background.png" id="wRB-Sh-K8J" userLabel="domainField" customClass="UILinphoneTextField">
<rect key="frame" x="33" y="230" width="255" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Domain">
<bool key="isElement" value="YES"/>
</accessibility>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocorrectionType="no"/>
<connections>
<outlet property="delegate" destination="-1" id="2Cp-Qo-wte"/>
</connections>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" id="dGS-GB-Sgb" userLabel="signInButton" customClass="UILinphoneButton">
<rect key="frame" x="34" y="330" width="255" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES"/>
<accessibility key="accessibilityConfiguration" label="Sign in"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
<state key="normal" title="Sign in" backgroundImage="button_background_default.png">
<color key="titleColor" red="0.35686274509999999" green="0.39607843139999999" blue="0.43529411759999997" alpha="1" colorSpace="deviceRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted" backgroundImage="button_background_over.png">
<color key="titleColor" red="0.72549019609999998" green="0.76862745099999996" blue="0.79607843140000001" alpha="1" colorSpace="deviceRGB"/>
</state>
<connections>
<action selector="onProvisionedLoginClick:" destination="-1" eventType="touchUpInside" id="vdT-jh-r0K"/>
</connections>
</button>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="These parameters were retrieved from a remote provisioning profile." textAlignment="center" lineBreakMode="wordWrap" numberOfLines="7" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="RHE-hi-dfB" userLabel="remoteParamsLabel">
<rect key="frame" x="34" y="269.0000019583353" width="254" height="53"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>

View file

@ -42,6 +42,7 @@
@property (nonatomic, retain) IBOutlet UIView *connectAccountView;
@property (nonatomic, retain) IBOutlet UIView *externalAccountView;
@property (nonatomic, retain) IBOutlet UIView *validateAccountView;
@property (retain, nonatomic) IBOutlet UIView *provisionedAccountView;
@property (nonatomic, retain) IBOutlet UIView *waitView;
@ -51,8 +52,10 @@
@property (nonatomic, retain) IBOutlet UIButton *connectAccountButton;
@property (nonatomic, retain) IBOutlet UIButton *externalAccountButton;
@property (retain, nonatomic) IBOutlet UIButton *remoteProvisioningButton;
@property (retain, nonatomic) IBOutlet UILabel *remoteParamsLabel;
@property (retain, nonatomic) IBOutlet UITextField *provisionedUsername;
@property (retain, nonatomic) IBOutlet UITextField *provisionedPassword;
@property (retain, nonatomic) IBOutlet UITextField *provisionedDomain;
@property (nonatomic, retain) IBOutlet UIImageView *choiceViewLogoImageView;
@ -74,5 +77,6 @@
- (IBAction)onSignInClick:(id)sender;
- (IBAction)onSignInExternalClick:(id)sender;
- (IBAction)onRegisterClick:(id)sender;
- (IBAction)onProvisionedLoginClick:(id)sender;
@end

View file

@ -32,7 +32,6 @@ typedef enum _ViewElement {
ViewElement_Password2 = 102,
ViewElement_Email = 103,
ViewElement_Domain = 104,
ViewElement_RemoteProvDetails = 105,
ViewElement_Label = 200,
ViewElement_Error = 201,
ViewElement_Username_Error = 404
@ -48,7 +47,7 @@ typedef enum _ViewElement {
@synthesize connectAccountView;
@synthesize externalAccountView;
@synthesize validateAccountView;
@synthesize provisionedAccountView;
@synthesize waitView;
@synthesize backButton;
@ -57,7 +56,8 @@ typedef enum _ViewElement {
@synthesize connectAccountButton;
@synthesize externalAccountButton;
@synthesize remoteProvisioningButton;
@synthesize remoteParamsLabel;
@synthesize provisionedDomain, provisionedPassword, provisionedUsername;
@synthesize choiceViewLogoImageView;
@ -106,7 +106,10 @@ typedef enum _ViewElement {
[viewTapGestureRecognizer release];
[remoteProvisioningButton release];
[remoteParamsLabel release];
[provisionedAccountView release];
[provisionedUsername release];
[provisionedPassword release];
[provisionedDomain release];
[super dealloc];
}
@ -157,7 +160,6 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[remoteParamsLabel setHidden:TRUE];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:kLinphoneRegistrationUpdate
object:nil];
@ -188,6 +190,7 @@ static UICompositeViewDescription *compositeDescription = nil;
[LinphoneUtils adjustFontSize:connectAccountView mult:2.22f];
[LinphoneUtils adjustFontSize:externalAccountView mult:2.22f];
[LinphoneUtils adjustFontSize:validateAccountView mult:2.22f];
[LinphoneUtils adjustFontSize:provisionedAccountView mult:2.22f];
}
}
@ -207,7 +210,6 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)fillDefaultValues {
LinphoneCore* lc = [LinphoneManager getLc];
[self resetTextFields];
LinphoneProxyConfig* current_conf = NULL;
@ -235,20 +237,18 @@ static UICompositeViewDescription *compositeDescription = nil;
const char* domain = linphone_address_get_domain(default_addr);
const char* username = linphone_address_get_username(default_addr);
if( domain && strlen(domain) > 0){
UITextField* domainfield = [WizardViewController findTextField:ViewElement_Domain view:externalAccountView];
[domainfield setText:[NSString stringWithUTF8String:domain]];
//UITextField* domainfield = [WizardViewController findTextField:ViewElement_Domain view:externalAccountView];
[provisionedDomain setText:[NSString stringWithUTF8String:domain]];
}
if( username && strlen(username) > 0 && username[0] != '?' ){
UITextField* userField = [WizardViewController findTextField:ViewElement_Username view:externalAccountView];
[userField setText:[NSString stringWithUTF8String:username]];
//UITextField* userField = [WizardViewController findTextField:ViewElement_Username view:externalAccountView];
[provisionedUsername setText:[NSString stringWithUTF8String:username]];
}
}
}
[self changeView:externalAccountView back:FALSE animation:TRUE];
[remoteParamsLabel setHidden:FALSE];
[self changeView:provisionedAccountView back:FALSE animation:TRUE];
linphone_proxy_config_destroy(default_conf);
@ -261,6 +261,7 @@ static UICompositeViewDescription *compositeDescription = nil;
[WizardViewController cleanTextField:connectAccountView];
[WizardViewController cleanTextField:externalAccountView];
[WizardViewController cleanTextField:validateAccountView];
[WizardViewController cleanTextField:provisionedAccountView];
}
- (void)reset {
@ -481,7 +482,8 @@ static UICompositeViewDescription *compositeDescription = nil;
int defaultExpire = [[LinphoneManager instance] lpConfigIntForKey:@"default_expires"];
if (defaultExpire >= 0)
linphone_proxy_config_expires(proxyCfg, defaultExpire);
if([domain compare:[[LinphoneManager instance] lpConfigStringForKey:@"domain" forSection:@"wizard"] options:NSCaseInsensitiveSearch] == 0) {
if(([domain compare:[[LinphoneManager instance] lpConfigStringForKey:@"domain" forSection:@"wizard"] options:NSCaseInsensitiveSearch] == 0)
&& ! [LinphoneManager instance].wasRemoteProvisioned ) {
[self setDefaultSettings:proxyCfg];
}
linphone_proxy_config_enable_register(proxyCfg, true);
@ -490,6 +492,34 @@ static UICompositeViewDescription *compositeDescription = nil;
linphone_core_set_default_proxy([LinphoneManager getLc], proxyCfg);
}
- (void)addProvisionedProxy:(NSString*)username withPassword:(NSString*)password withDomain:(NSString*)domain {
[self clearProxyConfig];
LinphoneProxyConfig* proxyCfg = linphone_core_create_proxy_config([LinphoneManager getLc]);
const char *addr= linphone_proxy_config_get_domain(proxyCfg);
char normalizedUsername[256];
LinphoneAddress* linphoneAddress = linphone_address_new(addr);
linphone_proxy_config_normalize_number(proxyCfg,
[username cStringUsingEncoding:[NSString defaultCStringEncoding]],
normalizedUsername,
sizeof(normalizedUsername));
linphone_address_set_username(linphoneAddress, normalizedUsername);
linphone_address_set_domain(linphoneAddress, [domain UTF8String]);
const char* identity = linphone_address_as_string_uri_only(linphoneAddress);
linphone_proxy_config_set_identity(proxyCfg, identity);
LinphoneAuthInfo* info = linphone_auth_info_new([username UTF8String], NULL, [password UTF8String], NULL, NULL, [domain UTF8String]);
linphone_proxy_config_enable_register(proxyCfg, true);
linphone_core_add_auth_info([LinphoneManager getLc], info);
linphone_core_add_proxy_config([LinphoneManager getLc], proxyCfg);
linphone_core_set_default_proxy([LinphoneManager getLc], proxyCfg);
}
- (NSString*)identityFromUsername:(NSString*)username {
char normalizedUserName[256];
LinphoneAddress* linphoneAddress = linphone_address_new("sip:user@domain.com");
@ -789,6 +819,30 @@ static UICompositeViewDescription *compositeDescription = nil;
}
}
- (IBAction)onProvisionedLoginClick:(id)sender {
NSString *username = provisionedUsername.text;
NSString *password = provisionedPassword.text;
NSMutableString *errors = [NSMutableString string];
if ([username length] == 0) {
[errors appendString:[NSString stringWithFormat:NSLocalizedString(@"Please enter a username.\n", nil)]];
}
if([errors length]) {
UIAlertView* errorView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Check error(s)",nil)
message:[errors substringWithRange:NSMakeRange(0, [errors length] - 1)]
delegate:nil
cancelButtonTitle:NSLocalizedString(@"Continue",nil)
otherButtonTitles:nil,nil];
[errorView show];
[errorView release];
} else {
[self.waitView setHidden:false];
[self addProvisionedProxy:username withPassword:password withDomain:provisionedDomain.text];
}
}
- (IBAction)onViewTap:(id)sender {
[LinphoneUtils findAndResignFirstResponder:currentView];
}