diff --git a/.git-pre-commit b/.git-pre-commit index 69a71bea9..76e3a9ab1 100755 --- a/.git-pre-commit +++ b/.git-pre-commit @@ -5,47 +5,53 @@ # From https://github.com/tatsuhiro-t/nghttp2/blob/master/pre-commit -function invalid-format-detected { - cat git-clang-format.diff - echo "*****************" - echo "$0: Invalid coding style detected (see git-clang-format.diff for issues). Please correct it using one of the following:" - echo "1) Apply patch located at git-clang-format.diff using:" - echo " cd $(git rev-parse --show-toplevel) && $1" - echo "2) Use clang-format to correctly format source code using:" - echo " $2" - echo "3) Reformat these lines manually." - echo "*** Aborting commit.***" - exit 1 -} +git_clang_format_path="$(which git-clang-format)" +clang_format_path=$(find /usr/bin /usr/local/bin/ -name 'clang-format-diff*' -type f -maxdepth 1 | tail -n1) + + function git-clang-format-diffing { - format_diff=$(which git-clang-format) - format_diff_options="--style=file" + options="--style=file" #only diffing commited files, ignored staged one - $format_diff $format_diff_options --diff $(git --no-pager diff --cached --name-status | grep -v '^D' | cut -f2) > git-clang-format.diff + $git_clang_format_path $options --diff $(git --no-pager diff --cached --name-status | grep -v '^D' | cut -f2) > diff-format.patch - if ! grep -q -E '(no modified files to format|clang-format did not modify any files)' git-clang-format.diff; then - invalid-format-detected "git apply git-clang-format.diff" "clang-format $format_diff_options -i " + if grep -q -E '(no modified files to format|clang-format did not modify any files)' diff-format.patch; then + rm diff-format.patch fi } function clang-format-diff-diffing { - format_diff=$(find /usr/bin/ -name 'clang-format-diff*' -type f | tail -n1) - format_diff_options="-style file" + options="-style file" - git diff-index --cached --diff-filter=ACMR -p HEAD -- | $format_diff $format_diff_options -p1 > git-clang-format.diff - if [ -s git-clang-format.diff ]; then - invalid-format-detected "patch -p0 < git-clang-format.diff" "${format_diff/-diff/} $format_diff_options -i " + git diff-index --cached --diff-filter=ACMR -p HEAD -- | $clang_format_path $options -p1 > file-format.patch + if [ ! -s file-format.patch ]; then + rm file-format.patch fi } set -e -if which git-clang-format &>/dev/null; then - git-clang-format-diffing $@ -elif [ ! -z "$(find /usr/bin/ /usr/local/bin/ /opt/bin/ -name 'clang-format-diff*' -type f 2>/dev/null)" ]; then - # Warning! We need at least version 1.6... - clang-format-diff-diffing $@ -else + +if [ -z "$git_clang_format_path$clang_format_path" ]; then echo "$0: Please install clang-format (coding style checker) - could not find git-clang-format nor clang-format-diff in PATH. Skipping code verification..." exit 0 fi + +if [ ! -z "$git_clang_format_path" ]; then + git-clang-format-diffing +fi + +if [ ! -z "$clang_format_path" ]; then + # Warning! We need at least version 1.6... + clang-format-diff-diffing +fi + +if [ -f diff-format.patch ] || [ -f file-format.patch ]; then + [ -f diff-format.patch ] && cat diff-format.patch + echo "**********************************************************************" + echo "$0: Invalid coding style detected. Please correct it using one of the following:" + echo "* Reformat these lines manually." + [ -f diff-format.patch ] && printf "* Apply diff patch using:\n\tcd $(git rev-parse --show-toplevel) && git apply diff-format.patch\n" + [ -f file-format.patch ] && printf "* Apply diff patch using:\n\tpatch -p0 < file-format.patch\n" + echo "*** Aborting commit.***" + exit 1 +fi diff --git a/.gitignore b/.gitignore index 20dcb5af7..10fd37fe5 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ submodules/tunnel submodules/binaries/dummy-*.a linphone-iphone.ipa TutorialHellowWorld/hello-world.xcodeproj/project.xcworkspace/ +diff-format.patch diff --git a/.gitmodules b/.gitmodules index d1862f96a..39e2ab1a7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -91,3 +91,6 @@ [submodule "submodules/belcard"] path = submodules/belcard url = git://git.linphone.org/belcard +[submodule "submodules/bctoolbox"] + path = submodules/bctoolbox + url = git://git.linphone.org/bctoolbox diff --git a/Classes/AboutView.h b/Classes/AboutView.h index cf06159a4..0fd2aca63 100644 --- a/Classes/AboutView.h +++ b/Classes/AboutView.h @@ -21,18 +21,12 @@ #import "UICompositeView.h" -@interface AboutView : UIViewController { -} - -@property(nonatomic, strong) IBOutlet UILabel *linphoneLabel; -@property(nonatomic, strong) IBOutlet UILabel *linphoneIphoneVersionLabel; -@property(nonatomic, strong) IBOutlet UILabel *linphoneCoreVersionLabel; -@property(nonatomic, strong) IBOutlet UILabel *linkLabel; -@property(nonatomic, strong) IBOutlet UILabel *copyrightLabel; -@property(nonatomic, strong) IBOutlet UILabel *licenseLabel; -@property(weak, nonatomic) IBOutlet UIView *contentView; -@property(nonatomic, strong) IBOutlet UIWebView *licensesView; +@interface AboutView : TPMultiLayoutViewController +@property(weak, nonatomic) IBOutlet UILabel *nameLabel; +@property(weak, nonatomic) IBOutlet UILabel *descriptionLabel; +@property(weak, nonatomic) IBOutlet UILabel *appVersionLabel; +@property(weak, nonatomic) IBOutlet UILabel *libVersionLabel; - (IBAction)onLinkTap:(id)sender; - (IBAction)onDialerBackClick:(id)sender; diff --git a/Classes/AboutView.m b/Classes/AboutView.m index 884a34013..dda1604ec 100644 --- a/Classes/AboutView.m +++ b/Classes/AboutView.m @@ -19,43 +19,10 @@ #import "PhoneMainView.h" #import "LinphoneManager.h" -#include "linphone/lpconfig.h" -#include "LinphoneIOSVersion.h" +#import "LinphoneIOSVersion.h" @implementation AboutView -#pragma mark - ViewController Functions - -- (void)viewDidLoad { - [super viewDidLoad]; - - UIScrollView *scrollView = (UIScrollView *)self.view; - [scrollView addSubview:_contentView]; - [scrollView setContentSize:[_contentView bounds].size]; - - [_linphoneLabel setText:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]]; - - [_linphoneIphoneVersionLabel - setText:[NSString stringWithFormat:@"%@ iPhone %@", - [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"], - [NSString stringWithUTF8String:LINPHONE_IOS_VERSION]]]; - - [_linphoneCoreVersionLabel - setText:[NSString stringWithFormat:@"%@ Core %s", - [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"], - linphone_core_get_version()]]; - - [AboutView removeBackground:_licensesView]; - - // Create a request to the resource - NSURLRequest *request = - [NSURLRequest requestWithURL:[NSURL fileURLWithPath:[LinphoneManager bundleFile:@"licenses.html"]]]; - // Load the resource using the request - [_licensesView setDelegate:self]; - [_licensesView loadRequest:request]; - [[AboutView defaultScrollView:_licensesView] setScrollEnabled:FALSE]; -} - #pragma mark - UICompositeViewDelegate Functions static UICompositeViewDescription *compositeDescription = nil; @@ -77,54 +44,24 @@ static UICompositeViewDescription *compositeDescription = nil; return self.class.compositeViewDescription; } -#pragma mark - +#pragma mark - ViewController Functions -+ (void)removeBackground:(UIView *)view { - for (UIView *subview in [view subviews]) { - [subview setOpaque:NO]; - [subview setBackgroundColor:[UIColor clearColor]]; - } - [view setOpaque:NO]; - [view setBackgroundColor:[UIColor clearColor]]; -} - -+ (UIScrollView *)defaultScrollView:(UIWebView *)webView { - return webView.scrollView; +- (void)viewDidLoad { + [super viewDidLoad]; + NSString *name = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"]; + _nameLabel.text = name; + _appVersionLabel.text = [NSString stringWithFormat:@"%@ iOS %s", name, LINPHONE_IOS_VERSION]; + _libVersionLabel.text = [NSString stringWithFormat:@"%@ Core %s", name, linphone_core_get_version()]; } #pragma mark - Action Functions - (IBAction)onLinkTap:(id)sender { - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:_linkLabel.text]]; -} - -#pragma mark - UIWebViewDelegate Functions - -- (void)webViewDidFinishLoad:(UIWebView *)webView { - CGSize size = [webView sizeThatFits:CGSizeMake(self.view.bounds.size.width, 10000.0f)]; - float diff = size.height - webView.bounds.size.height; - - CGRect contentFrame = [self.view bounds]; - contentFrame.size.height += diff; - [_contentView setAutoresizesSubviews:FALSE]; - [_contentView setFrame:contentFrame]; - [_contentView setAutoresizesSubviews:TRUE]; - [(UIScrollView *)self.view setContentSize:contentFrame.size]; - - CGRect licensesViewFrame = [_licensesView frame]; - licensesViewFrame.size.height += diff; - [_licensesView setFrame:licensesViewFrame]; -} - -- (BOOL)webView:(UIWebView *)inWeb - shouldStartLoadWithRequest:(NSURLRequest *)inRequest - navigationType:(UIWebViewNavigationType)inType { - if (inType == UIWebViewNavigationTypeLinkClicked) { - [[UIApplication sharedApplication] openURL:[inRequest URL]]; - return NO; + UIGestureRecognizer *gest = sender; + NSString *url = ((UILabel *)gest.view).text; + if (![UIApplication.sharedApplication openURL:[NSURL URLWithString:url]]) { + LOGE(@"Failed to open %@, invalid URL", url); } - - return YES; } - (IBAction)onDialerBackClick:(id)sender { diff --git a/Classes/AssistantView.h b/Classes/AssistantView.h index 2ee58224c..fc9d42873 100644 --- a/Classes/AssistantView.h +++ b/Classes/AssistantView.h @@ -70,6 +70,4 @@ - (IBAction)onRemoteProvisioningLoginClick:(id)sender; - (IBAction)onRemoteProvisioningDownloadClick:(id)sender; -- (IBAction)onTransportChange:(id)sender; - @end diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index daa9e9877..86cd728d9 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -225,6 +225,16 @@ static UICompositeViewDescription *compositeDescription = nil; } } + // set transport + UISegmentedControl *transports = (UISegmentedControl *)[self findView:ViewElement_Transport + inView:self.contentView + ofType:UISegmentedControl.class]; + if (transports) { + NSString *type = [transports titleForSegmentAtIndex:[transports selectedSegmentIndex]]; + linphone_account_creator_set_transport(account_creator, + linphone_transport_parse(type.lowercaseString.UTF8String)); + } + new_config = linphone_account_creator_configure(account_creator); if (new_config) { @@ -233,6 +243,17 @@ static UICompositeViewDescription *compositeDescription = nil; // reload address book to prepend proxy config domain to contacts' phone number // todo: STOP doing that! [[LinphoneManager.instance fastAddressBook] reload]; + } else { + UIAlertView *error = [[UIAlertView alloc] + initWithTitle:NSLocalizedString(@"Assistant error", nil) + message:NSLocalizedString( + @"Could not configure your account, please check parameters or try again later", nil) + delegate:nil + cancelButtonTitle:NSLocalizedString(@"Cancel", nil) + otherButtonTitles:nil]; + [error show]; + _waitView.hidden = YES; + return; } } @@ -477,9 +498,11 @@ static UICompositeViewDescription *compositeDescription = nil; UIAssistantTextField *displayName = [self findTextField:ViewElement_DisplayName]; [displayName showError:[AssistantView errorForStatus:LinphoneAccountCreatorDisplayNameInvalid] when:^BOOL(NSString *inputEntry) { - LinphoneAccountCreatorStatus s = - linphone_account_creator_set_display_name(account_creator, inputEntry.UTF8String); - displayName.errorLabel.text = [AssistantView errorForStatus:s]; + LinphoneAccountCreatorStatus s = LinphoneAccountCreatorOK; + if (inputEntry.length > 0) { + s = linphone_account_creator_set_display_name(account_creator, inputEntry.UTF8String); + displayName.errorLabel.text = [AssistantView errorForStatus:s]; + } return s != LinphoneAccountCreatorOK; }]; @@ -516,9 +539,6 @@ static UICompositeViewDescription *compositeDescription = nil; } case LinphoneRegistrationFailed: { _waitView.hidden = true; - if ([message isEqualToString:@"Forbidden"]) { - message = NSLocalizedString(@"Incorrect username or password.", nil); - } DTAlertView *alert = [[DTAlertView alloc] initWithTitle:NSLocalizedString(@"Registration failure", nil) message:message delegate:nil @@ -728,12 +748,6 @@ void assistant_validation_tested(LinphoneAccountCreator *creator, LinphoneAccoun [self resetLiblinphone]; } -- (IBAction)onTransportChange:(id)sender { - UISegmentedControl *transports = sender; - NSString *type = [transports titleForSegmentAtIndex:[transports selectedSegmentIndex]]; - linphone_account_creator_set_transport(account_creator, linphone_transport_parse(type.lowercaseString.UTF8String)); -} - - (IBAction)onBackClick:(id)sender { if ([historyViews count] > 0) { UIView *view = [historyViews lastObject]; diff --git a/Classes/Base.lproj/AboutView.strings b/Classes/Base.lproj/AboutView.strings index 5cce46d13..d4a070336 100644 Binary files a/Classes/Base.lproj/AboutView.strings and b/Classes/Base.lproj/AboutView.strings differ diff --git a/Classes/Base.lproj/AboutView.xib b/Classes/Base.lproj/AboutView.xib index 8ea48f462..5dc9bf2d2 100644 --- a/Classes/Base.lproj/AboutView.xib +++ b/Classes/Base.lproj/AboutView.xib @@ -1,21 +1,19 @@ - + - + - - - - - - - - - + + + + + + + @@ -23,23 +21,21 @@ - - - + + + - - + + - - + + - - - - - - - + + + - - - - + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + - + diff --git a/Classes/Base.lproj/AssistantViewScreens.xib b/Classes/Base.lproj/AssistantViewScreens.xib index 42b5e62eb..78f78f123 100644 --- a/Classes/Base.lproj/AssistantViewScreens.xib +++ b/Classes/Base.lproj/AssistantViewScreens.xib @@ -1,5 +1,5 @@ - + @@ -577,9 +577,6 @@ Once it is done, come back here and click on the button. - - -