fix wizard

This commit is contained in:
Gautier Pelloux-Prayer 2015-09-10 15:08:45 +02:00
parent 6f49182c4c
commit 4b87055a9b
6 changed files with 228 additions and 242 deletions

View file

@ -22,8 +22,8 @@
#import "UICompositeView.h"
#import "TPKeyboardAvoidingScrollView.h"
@interface AssistantView : TPMultiLayoutViewController <UITextFieldDelegate, UICompositeViewDelegate,
XMLRPCConnectionDelegate, UIAlertViewDelegate> {
@interface AssistantView
: TPMultiLayoutViewController <UITextFieldDelegate, UICompositeViewDelegate, XMLRPCConnectionDelegate> {
@private
UITextField *activeTextField;
UIView *currentView;
@ -31,22 +31,22 @@
NSMutableArray *historyViews;
}
@property(nonatomic, weak) IBOutlet TPKeyboardAvoidingScrollView *contentView;
@property(nonatomic, weak) IBOutlet UIView *waitView;
@property(nonatomic, weak) IBOutlet UIButton *backButton;
@property(nonatomic, strong) IBOutlet TPKeyboardAvoidingScrollView *contentView;
@property(nonatomic, strong) IBOutlet UIView *waitView;
@property(nonatomic, strong) IBOutlet UIButton *backButton;
@property(nonatomic, weak) IBOutlet UIView *welcomeView;
@property(nonatomic, weak) IBOutlet UIView *createAccountView;
@property(nonatomic, weak) IBOutlet UIView *createAccountActivationView;
@property(nonatomic, weak) IBOutlet UIView *linphoneLoginView;
@property(nonatomic, weak) IBOutlet UIView *loginView;
@property(weak, nonatomic) IBOutlet UIView *remoteProvisionningView;
@property(nonatomic, strong) IBOutlet UIView *welcomeView;
@property(nonatomic, strong) IBOutlet UIView *createAccountView;
@property(nonatomic, strong) IBOutlet UIView *createAccountActivationView;
@property(nonatomic, strong) IBOutlet UIView *linphoneLoginView;
@property(nonatomic, strong) IBOutlet UIView *loginView;
@property(nonatomic, strong) IBOutlet UIView *remoteProvisionningView;
@property(nonatomic, weak) IBOutlet UIImageView *welcomeLogoImage;
@property(nonatomic, weak) IBOutlet UIButton *gotoCreateAccountButton;
@property(nonatomic, weak) IBOutlet UIButton *gotoLinphoneLoginButton;
@property(nonatomic, weak) IBOutlet UIButton *gotoLoginButton;
@property(weak, nonatomic) IBOutlet UIButton *gotoRemoteProvisionningButton;
@property(nonatomic, strong) IBOutlet UIImageView *welcomeLogoImage;
@property(nonatomic, strong) IBOutlet UIButton *gotoCreateAccountButton;
@property(nonatomic, strong) IBOutlet UIButton *gotoLinphoneLoginButton;
@property(nonatomic, strong) IBOutlet UIButton *gotoLoginButton;
@property(nonatomic, strong) IBOutlet UIButton *gotoRemoteProvisionningButton;
- (void)reset;
- (void)fillDefaultValues;

View file

@ -112,6 +112,12 @@ static UICompositeViewDescription *compositeDescription = nil;
}
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[_contentView contentSizeToFit];
}
#pragma mark - Utils
- (void)displayUsernameAsPhoneOrUsername {
BOOL usePhoneNumber = [LinphoneManager.instance lpConfigBoolForKey:@"use_phone_number"];
@ -127,7 +133,109 @@ static UICompositeViewDescription *compositeDescription = nil;
}
}
#pragma mark -
- (BOOL)verificationWithUsername:(NSString *)username
password:(NSString *)password
domain:(NSString *)domain
withTransport:(NSString *)transport {
NSMutableString *errors = [NSMutableString string];
if ([username length] == 0) {
[errors appendString:[NSString stringWithFormat:NSLocalizedString(@"Please enter a valid username.\n", nil)]];
}
if (domain != nil && [domain length] == 0) {
[errors appendString:[NSString stringWithFormat:NSLocalizedString(@"Please enter a valid domain.\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];
return FALSE;
}
return TRUE;
}
- (void)verificationSignInWithUsername:(NSString *)username
password:(NSString *)password
domain:(NSString *)domain
withTransport:(NSString *)transport {
if ([self verificationWithUsername:username password:password domain:domain withTransport:transport]) {
_waitView.hidden = false;
if ([LinphoneManager instance].connectivity == none) {
DTAlertView *alert = [[DTAlertView alloc]
initWithTitle:NSLocalizedString(@"No connectivity", nil)
message:NSLocalizedString(@"You can either skip verification or connect to the Internet first.",
nil)];
[alert addCancelButtonWithTitle:NSLocalizedString(@"Stay here", nil)
block:^{
_waitView.hidden = true;
}];
[alert
addButtonWithTitle:NSLocalizedString(@"Continue", nil)
block:^{
_waitView.hidden = true;
[self addProxyConfig:username password:password domain:domain withTransport:transport];
[PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription];
}];
[alert show];
} else {
BOOL success = [self addProxyConfig:username password:password domain:domain withTransport:transport];
if (!success) {
_waitView.hidden = true;
}
}
}
}
- (BOOL)verificationRegisterWithUsername:(NSString *)username
password:(NSString *)password
password2:(NSString *)password2
email:(NSString *)email {
NSMutableString *errors = [NSMutableString string];
NSInteger username_length =
[[LinphoneManager instance] lpConfigIntForKey:@"username_length" forSection:@"assistant"];
NSInteger password_length =
[[LinphoneManager instance] lpConfigIntForKey:@"password_length" forSection:@"assistant"];
if ([username length] < username_length) {
[errors
appendString:[NSString stringWithFormat:NSLocalizedString(
@"The username is too short (minimum %d characters).\n", nil),
username_length]];
}
if ([password length] < password_length) {
[errors
appendString:[NSString stringWithFormat:NSLocalizedString(
@"The password is too short (minimum %d characters).\n", nil),
password_length]];
}
if (![password2 isEqualToString:password]) {
[errors appendString:NSLocalizedString(@"The passwords are different.\n", nil)];
}
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", @".+@.+\\.[A-Za-z]{2}[A-Za-z]*"];
if (![emailTest evaluateWithObject:email]) {
[errors appendString:NSLocalizedString(@"The email is invalid.\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];
return FALSE;
}
return TRUE;
}
+ (void)cleanTextField:(UIView *)view {
if ([view isKindOfClass:[UITextField class]]) {
@ -140,7 +248,6 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (void)fillDefaultValues {
LinphoneCore *lc = [LinphoneManager getLc];
[self resetTextFields];
@ -243,7 +350,7 @@ static UICompositeViewDescription *compositeDescription = nil;
static BOOL placement_done = NO; // indicates if the button placement has been done in the assistant choice view
// Change toolbar buttons following view
_backButton.enabled = (view == _welcomeView);
_backButton.enabled = (view != _welcomeView);
[self displayUsernameAsPhoneOrUsername];
@ -423,54 +530,6 @@ static UICompositeViewDescription *compositeDescription = nil;
return [uri substringFromIndex:[scheme length] + 1];
}
#pragma mark - Linphone XMLRPC
- (void)checkUserExist:(NSString *)username {
LOGI(@"XMLRPC check_account %@", username);
NSURL *URL =
[NSURL URLWithString:[[LinphoneManager instance] lpConfigStringForKey:@"service_url" forSection:@"assistant"]];
XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithURL:URL];
[request setMethod:@"check_account" withParameters:[NSArray arrayWithObjects:username, nil]];
XMLRPCConnectionManager *manager = [XMLRPCConnectionManager sharedManager];
[manager spawnConnectionWithXMLRPCRequest:request delegate:self];
_waitView.hidden = false;
}
- (void)createAccount:(NSString *)identity password:(NSString *)password email:(NSString *)email {
NSString *useragent = [LinphoneManager getUserAgent];
LOGI(@"XMLRPC create_account_with_useragent %@ %@ %@ %@", identity, password, email, useragent);
NSURL *URL =
[NSURL URLWithString:[[LinphoneManager instance] lpConfigStringForKey:@"service_url" forSection:@"assistant"]];
XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithURL:URL];
[request setMethod:@"create_account_with_useragent"
withParameters:[NSArray arrayWithObjects:identity, password, email, useragent, nil]];
XMLRPCConnectionManager *manager = [XMLRPCConnectionManager sharedManager];
[manager spawnConnectionWithXMLRPCRequest:request delegate:self];
_waitView.hidden = false;
}
- (void)checkAccountValidation:(NSString *)identity {
LOGI(@"XMLRPC check_account_validated %@", identity);
NSURL *URL =
[NSURL URLWithString:[[LinphoneManager instance] lpConfigStringForKey:@"service_url" forSection:@"assistant"]];
XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithURL:URL];
[request setMethod:@"check_account_validated" withParameters:[NSArray arrayWithObjects:identity, nil]];
XMLRPCConnectionManager *manager = [XMLRPCConnectionManager sharedManager];
[manager spawnConnectionWithXMLRPCRequest:request delegate:self];
_waitView.hidden = false;
}
#pragma mark -
- (void)registrationUpdate:(LinphoneRegistrationState)state
forProxy:(LinphoneProxyConfig *)proxy
message:(NSString *)message {
@ -528,6 +587,52 @@ static UICompositeViewDescription *compositeDescription = nil;
linphone_core_set_default_proxy_config([LinphoneManager getLc], NULL);
}
#pragma mark - Linphone XMLRPC
- (void)checkUserExist:(NSString *)username {
LOGI(@"XMLRPC check_account %@", username);
NSURL *URL =
[NSURL URLWithString:[[LinphoneManager instance] lpConfigStringForKey:@"service_url" forSection:@"assistant"]];
XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithURL:URL];
[request setMethod:@"check_account" withParameters:[NSArray arrayWithObjects:username, nil]];
XMLRPCConnectionManager *manager = [XMLRPCConnectionManager sharedManager];
[manager spawnConnectionWithXMLRPCRequest:request delegate:self];
_waitView.hidden = false;
}
- (void)createAccount:(NSString *)identity password:(NSString *)password email:(NSString *)email {
NSString *useragent = [LinphoneManager getUserAgent];
LOGI(@"XMLRPC create_account_with_useragent %@ %@ %@ %@", identity, password, email, useragent);
NSURL *URL =
[NSURL URLWithString:[[LinphoneManager instance] lpConfigStringForKey:@"service_url" forSection:@"assistant"]];
XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithURL:URL];
[request setMethod:@"create_account_with_useragent"
withParameters:[NSArray arrayWithObjects:identity, password, email, useragent, nil]];
XMLRPCConnectionManager *manager = [XMLRPCConnectionManager sharedManager];
[manager spawnConnectionWithXMLRPCRequest:request delegate:self];
_waitView.hidden = false;
}
- (void)checkAccountValidation:(NSString *)identity {
LOGI(@"XMLRPC check_account_validated %@", identity);
NSURL *URL =
[NSURL URLWithString:[[LinphoneManager instance] lpConfigStringForKey:@"service_url" forSection:@"assistant"]];
XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithURL:URL];
[request setMethod:@"check_account_validated" withParameters:[NSArray arrayWithObjects:identity, nil]];
XMLRPCConnectionManager *manager = [XMLRPCConnectionManager sharedManager];
[manager spawnConnectionWithXMLRPCRequest:request delegate:self];
_waitView.hidden = false;
}
#pragma mark - UITextFieldDelegate Functions
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
@ -599,6 +704,39 @@ static UICompositeViewDescription *compositeDescription = nil;
#pragma mark - Action Functions
- (IBAction)onLoginClick:(id)sender {
NSString *username = [self findTextField:ViewElement_Username].text;
NSString *password = [self findTextField:ViewElement_Password].text;
NSString *domain = [self findTextField:ViewElement_Domain].text;
UISegmentedControl *transportChooser =
(UISegmentedControl *)[self findView:ViewElement_Transport inView:_contentView ofType:UISegmentedControl.class];
NSString *transport = [transportChooser titleForSegmentAtIndex:transportChooser.selectedSegmentIndex];
[self verificationSignInWithUsername:username password:password domain:domain withTransport:transport];
}
- (IBAction)onLinphoneLoginClick:(id)sender {
NSString *username = [self findTextField:ViewElement_Username].text;
NSString *password = [self findTextField:ViewElement_Password].text;
// domain and server will be configured from the default proxy values
[self verificationSignInWithUsername:username password:password domain:nil withTransport:nil];
}
- (IBAction)onCreateAccountClick:(id)sender {
UITextField *username_tf = [self findTextField:ViewElement_Username];
NSString *username = username_tf.text;
NSString *password = [self findTextField:ViewElement_Password].text;
NSString *password2 = [self findTextField:ViewElement_Password2].text;
NSString *email = [self findTextField:ViewElement_Email].text;
if ([self verificationRegisterWithUsername:username password:password password2:password2 email:email]) {
username = [username lowercaseString];
[username_tf setText:username];
NSString *identity = [self identityFromUsername:username];
[self checkUserExist:identity];
}
}
- (IBAction)onBackClick:(id)sender {
if ([historyViews count] > 0) {
UIView *view = [historyViews lastObject];
@ -648,143 +786,6 @@ static UICompositeViewDescription *compositeDescription = nil;
[remoteInput show];
}
- (BOOL)verificationWithUsername:(NSString *)username
password:(NSString *)password
domain:(NSString *)domain
withTransport:(NSString *)transport {
NSMutableString *errors = [NSMutableString string];
if ([username length] == 0) {
[errors appendString:[NSString stringWithFormat:NSLocalizedString(@"Please enter a valid username.\n", nil)]];
}
if (domain != nil && [domain length] == 0) {
[errors appendString:[NSString stringWithFormat:NSLocalizedString(@"Please enter a valid domain.\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];
return FALSE;
}
return TRUE;
}
- (void)verificationSignInWithUsername:(NSString *)username
password:(NSString *)password
domain:(NSString *)domain
withTransport:(NSString *)transport {
if ([self verificationWithUsername:username password:password domain:domain withTransport:transport]) {
_waitView.hidden = false;
if ([LinphoneManager instance].connectivity == none) {
DTAlertView *alert = [[DTAlertView alloc]
initWithTitle:NSLocalizedString(@"No connectivity", nil)
message:NSLocalizedString(@"You can either skip verification or connect to the Internet first.",
nil)];
[alert addCancelButtonWithTitle:NSLocalizedString(@"Stay here", nil)
block:^{
_waitView.hidden = true;
}];
[alert
addButtonWithTitle:NSLocalizedString(@"Continue", nil)
block:^{
_waitView.hidden = true;
[self addProxyConfig:username password:password domain:domain withTransport:transport];
[PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription];
}];
[alert show];
} else {
BOOL success = [self addProxyConfig:username password:password domain:domain withTransport:transport];
if (!success) {
_waitView.hidden = true;
}
}
}
}
- (IBAction)onLoginClick:(id)sender {
NSString *username = [self findTextField:ViewElement_Username].text;
NSString *password = [self findTextField:ViewElement_Password].text;
NSString *domain = [self findTextField:ViewElement_Domain].text;
UISegmentedControl *transportChooser =
(UISegmentedControl *)[self findView:ViewElement_Transport inView:_contentView ofType:UISegmentedControl.class];
NSString *transport = [transportChooser titleForSegmentAtIndex:transportChooser.selectedSegmentIndex];
[self verificationSignInWithUsername:username password:password domain:domain withTransport:transport];
}
- (IBAction)onLinphoneLoginClick:(id)sender {
NSString *username = [self findTextField:ViewElement_Username].text;
NSString *password = [self findTextField:ViewElement_Password].text;
// domain and server will be configured from the default proxy values
[self verificationSignInWithUsername:username password:password domain:nil withTransport:nil];
}
- (BOOL)verificationRegisterWithUsername:(NSString *)username
password:(NSString *)password
password2:(NSString *)password2
email:(NSString *)email {
NSMutableString *errors = [NSMutableString string];
NSInteger username_length =
[[LinphoneManager instance] lpConfigIntForKey:@"username_length" forSection:@"assistant"];
NSInteger password_length =
[[LinphoneManager instance] lpConfigIntForKey:@"password_length" forSection:@"assistant"];
if ([username length] < username_length) {
[errors
appendString:[NSString stringWithFormat:NSLocalizedString(
@"The username is too short (minimum %d characters).\n", nil),
username_length]];
}
if ([password length] < password_length) {
[errors
appendString:[NSString stringWithFormat:NSLocalizedString(
@"The password is too short (minimum %d characters).\n", nil),
password_length]];
}
if (![password2 isEqualToString:password]) {
[errors appendString:NSLocalizedString(@"The passwords are different.\n", nil)];
}
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", @".+@.+\\.[A-Za-z]{2}[A-Za-z]*"];
if (![emailTest evaluateWithObject:email]) {
[errors appendString:NSLocalizedString(@"The email is invalid.\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];
return FALSE;
}
return TRUE;
}
- (IBAction)onCreateAccountClick:(id)sender {
UITextField *username_tf = [self findTextField:ViewElement_Username];
NSString *username = username_tf.text;
NSString *password = [self findTextField:ViewElement_Password].text;
NSString *password2 = [self findTextField:ViewElement_Password2].text;
NSString *email = [self findTextField:ViewElement_Email].text;
if ([self verificationRegisterWithUsername:username password:password password2:password2 email:email]) {
username = [username lowercaseString];
[username_tf setText:username];
NSString *identity = [self identityFromUsername:username];
[self checkUserExist:identity];
}
}
- (IBAction)onRemoteProvisionningClick:(id)sender {
NSString *username = [self findTextField:ViewElement_Username].text;
NSString *password = [self findTextField:ViewElement_Password].text;
@ -810,29 +811,13 @@ static UICompositeViewDescription *compositeDescription = nil;
}
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[_contentView contentSizeToFit];
}
#pragma mark - Event Functions
#pragma mark - UIAlertViewDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) { /* fetch */
NSString *url = [alertView textFieldAtIndex:0].text;
if ([url length] > 0) {
// missing prefix will result in http:// being used
if ([url rangeOfString:@"://"].location == NSNotFound)
url = [NSString stringWithFormat:@"http://%@", url];
LOGI(@"Should use remote provisioning URL %@", url);
linphone_core_set_provisioning_uri([LinphoneManager getLc], [url UTF8String]);
_waitView.hidden = false;
[[LinphoneManager instance] resetLinphoneCore];
}
} else {
LOGI(@"Canceled remote provisioning");
}
- (void)registrationUpdateEvent:(NSNotification *)notif {
NSString *message = [notif.userInfo objectForKey:@"message"];
[self registrationUpdate:[[notif.userInfo objectForKey:@"state"] intValue]
forProxy:[[notif.userInfo objectForKeyedSubscript:@"cfg"] pointerValue]
message:message];
}
- (void)configuringUpdate:(NSNotification *)notif {
@ -866,15 +851,6 @@ static UICompositeViewDescription *compositeDescription = nil;
}
}
#pragma mark - Event Functions
- (void)registrationUpdateEvent:(NSNotification *)notif {
NSString *message = [notif.userInfo objectForKey:@"message"];
[self registrationUpdate:[[notif.userInfo objectForKey:@"state"] intValue]
forProxy:[[notif.userInfo objectForKeyedSubscript:@"cfg"] pointerValue]
message:message];
}
#pragma mark - XMLRPCConnectionDelegate Functions
- (void)request:(XMLRPCRequest *)request didReceiveResponse:(XMLRPCResponse *)response {

View file

@ -10,6 +10,7 @@
<outlet property="createAccountActivationView" destination="101" id="cxQ-rX-4fA"/>
<outlet property="createAccountView" destination="44" id="70"/>
<outlet property="gotoCreateAccountButton" destination="36" id="bZf-lI-yJp"/>
<outlet property="gotoLinphoneLoginButton" destination="38" id="K1E-r5-WiL"/>
<outlet property="gotoLoginButton" destination="39" id="uSY-cr-j4w"/>
<outlet property="gotoRemoteProvisionningButton" destination="Kbn-dL-C5h" id="pgT-y6-qKj"/>
<outlet property="linphoneLoginView" destination="52" id="9NX-6W-50g"/>
@ -527,7 +528,7 @@
</attributedString>
</state>
<connections>
<action selector="onLinphoneLoginClick:" destination="-1" eventType="touchUpInside" id="8FC-Mf-dX8"/>
<action selector="onLoginClick:" destination="-1" eventType="touchUpInside" id="LKg-hT-sDN"/>
</connections>
</button>
</subviews>
@ -637,7 +638,7 @@
</attributedString>
</state>
<connections>
<action selector="onLinphoneLoginClick:" destination="-1" eventType="touchUpInside" id="xx5-CI-tlx"/>
<action selector="onRemoteProvisionningClick:" destination="-1" eventType="touchUpInside" id="zsx-GM-Pjh"/>
</connections>
</button>
</subviews>

View file

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="AssistantView">
<connections>
<outlet property="backButton" destination="edC-CG-eZr" id="aXO-xT-kQ1"/>
<outlet property="contentView" destination="98" id="99"/>
<outlet property="portraitView" destination="12" id="117"/>
<outlet property="view" destination="12" id="20"/>

View file

@ -166,9 +166,11 @@ static UICompositeViewDescription *compositeDescription = nil;
self->chatRoom = room;
[messageField setText:@""];
[tableController setChatRoom:room];
[self update];
linphone_chat_room_mark_as_read(chatRoom);
[self setComposingVisible:linphone_chat_room_is_remote_composing(chatRoom) withDelay:0];
if (chatRoom != NULL) {
[self update];
linphone_chat_room_mark_as_read(chatRoom);
[self setComposingVisible:linphone_chat_room_is_remote_composing(chatRoom) withDelay:0];
}
[[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneMessageReceived object:self];
}

View file

@ -28,8 +28,12 @@
char *as_string = linphone_address_as_string(addr);
_addressLabel.text = [NSString stringWithUTF8String:as_string];
ms_free(as_string);
[FastAddressBook getContactImage:[FastAddressBook getContactWithLinphoneAddress:addr] thumbnail:NO];
} else {
_nameLabel.text = @"No account";
_addressLabel.text = NSLocalizedString(@"No address", nil);
}
// set avatar if available
NSURL *url = [NSURL URLWithString:[LinphoneManager.instance lpConfigStringForKey:@"avatar"]];
if (url) {
[LinphoneManager.instance.photoLibrary assetForURL:url
@ -42,7 +46,7 @@
});
}
failureBlock:^(NSError *error) {
LOGE(@"Can't read image");
LOGE(@"Can't read avatar");
}];
} else {
[_avatarImage setImage:[UIImage imageNamed:@"avatar"]];
@ -50,6 +54,7 @@
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self updateHeader];
[_sideMenuTableViewController.tableView reloadData];
}