diff --git a/.gitmodules b/.gitmodules index d5320a9ea..4a8a9c0e8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -117,3 +117,6 @@ [submodule "submodules/externals/soci"] path = submodules/externals/soci url = https://gitlab.linphone.org/BC/public/external/soci.git +[submodule "submodules/externals/zxing-cpp"] + path = submodules/externals/zxing-cpp + url = https://gitlab.linphone.org/BC/public/external/zxing-cpp.git diff --git a/Classes/AssistantView.h b/Classes/AssistantView.h index 3184f85bc..20a9de39a 100644 --- a/Classes/AssistantView.h +++ b/Classes/AssistantView.h @@ -21,6 +21,7 @@ #import "UICompositeView.h" #import "TPKeyboardAvoidingScrollView.h" #import "PhoneMainView.h" +#import @interface AssistantView : UIViewController { @@ -51,6 +52,7 @@ @property(nonatomic, strong) IBOutlet UIView *remoteProvisioningLoginView; @property(strong, nonatomic) IBOutlet UIView *remoteProvisioningView; @property (strong, nonatomic) IBOutlet UIView *createAccountActivateSMSView; +@property (strong, nonatomic) IBOutlet UIView *qrCodeView; @property(nonatomic, strong) IBOutlet UIImageView *welcomeLogoImage; @property(nonatomic, strong) IBOutlet UIButton *gotoCreateAccountButton; @@ -64,6 +66,9 @@ @property (weak, nonatomic) IBOutlet UILabel *activationSMSText; @property (weak, nonatomic) IBOutlet UILabel *accountLabel; +@property (weak, nonatomic) IBOutlet UIButton *qrCodeButton; +@property (weak, nonatomic) IBOutlet UIButton *downloadButton; +@property (weak, nonatomic) IBOutlet UITextField *urlLabel; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *createAccountNextButtonPositionConstraint; + (NSString *)StringForXMLRPCError:(const char *)err; @@ -92,6 +97,7 @@ - (IBAction)onLoginClick:(id)sender; - (IBAction)onRemoteProvisioningLoginClick:(id)sender; - (IBAction)onRemoteProvisioningDownloadClick:(id)sender; +- (IBAction)onLaunchQRCodeView:(id)sender; - (IBAction)onCreateAccountCheckActivatedClick:(id)sender; - (IBAction)onLinkAccountClick:(id)sender; diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index 8c8e238eb..caba5b1e6 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -28,6 +28,7 @@ #import "PhoneMainView.h" #import "UIAssistantTextField.h" #import "UITextField+DoneButton.h" +#import "LinphoneAppDelegate.h" typedef enum _ViewElement { ViewElement_Username = 100, @@ -117,6 +118,7 @@ static UICompositeViewDescription *compositeDescription = nil; } mustRestoreView = NO; _outgoingView = DialerView.compositeViewDescription; + _qrCodeButton.hidden = !ENABLE_QRCODE; [self resetLiblinphone:FALSE]; } @@ -134,6 +136,8 @@ static UICompositeViewDescription *compositeDescription = nil; [_contentView setContentSize:frame.size]; [_contentView contentSizeToFit]; + + _qrCodeView.frame = [[UIScreen mainScreen] bounds]; } - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { @@ -474,6 +478,13 @@ static UICompositeViewDescription *compositeDescription = nil; view = _linphoneLoginView; } } + + if (currentView == _qrCodeView) { + linphone_core_enable_video_preview(LC, FALSE); + linphone_core_enable_qrcode_video_preview(LC, FALSE); + LinphoneAppDelegate *delegate = (LinphoneAppDelegate *)UIApplication.sharedApplication.delegate; + delegate.onlyPortrait = FALSE; + } // Animation if (animation && ANIMATED) { @@ -1246,9 +1257,9 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun - (IBAction)onGotoRemoteProvisioningClick:(id)sender { ONCLICKBUTTON(sender, 100, { nextView = _remoteProvisioningView; - [self loadAssistantConfig:@"assistant_remote.rc"]; [self findTextField:ViewElement_URL].text = [LinphoneManager.instance lpConfigStringForKey:@"config-uri" inSection:@"misc"]; + [self loadAssistantConfig:@"assistant_remote.rc"]; }); } @@ -1396,6 +1407,49 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun }); } +- (IBAction)onLaunchQRCodeView:(id)sender { + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(qrCodeFound:) + name:kLinphoneQRCodeFound + object:nil]; + LinphoneAppDelegate *delegate = (LinphoneAppDelegate *)UIApplication.sharedApplication.delegate; + delegate.onlyPortrait = TRUE; + NSNumber *value = [NSNumber numberWithInt:UIDeviceOrientationPortrait]; + [[UIDevice currentDevice] setValue:value forKey:@"orientation"]; + //[UIViewController attemptRotationToDeviceOrientation]; + AVCaptureDevice *backCamera = [AVCaptureDevice defaultDeviceWithDeviceType:AVCaptureDeviceTypeBuiltInWideAngleCamera mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionBack]; + if (![[NSString stringWithUTF8String:linphone_core_get_video_device(LC)] containsString:[backCamera uniqueID]]) { + + bctbx_list_t *deviceList = linphone_core_get_video_devices_list(LC); + NSMutableArray *devices = [NSMutableArray array]; + + while (deviceList) { + char *data = deviceList->data; + [devices addObject:[NSString stringWithUTF8String:data]]; + deviceList = deviceList->next; + } + bctbx_list_free(deviceList); + + for (NSString *device in devices) { + if ([device containsString:backCamera.uniqueID]) { + linphone_core_set_video_device(LC, device.UTF8String); + } + } + } + + + linphone_core_set_native_preview_window_id(LC, (__bridge void *)(_qrCodeView)); + linphone_core_enable_video_preview(LC, TRUE); + linphone_core_enable_qrcode_video_preview(LC, TRUE); + + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(qrCodeFound:) + name:kLinphoneQRCodeFound + object:nil]; + + [self changeView:_qrCodeView back:FALSE animation:TRUE]; +} + - (void)refreshYourUsername { UIAssistantTextField *username = [self findTextField:ViewElement_Username]; UIAssistantTextField *phone = [self findTextField:ViewElement_Phone]; @@ -1509,7 +1563,7 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun - (IBAction)onBackClick:(id)sender { if ([historyViews count] > 0) { - if (currentView == _createAccountActivateSMSView || currentView == _createAccountActivateEmailView) { + if (currentView == _createAccountActivateSMSView || currentView == _createAccountActivateEmailView || currentView == _qrCodeView) { UIView *view = [historyViews lastObject]; [historyViews removeLastObject]; [self changeView:view back:TRUE animation:TRUE]; @@ -1532,7 +1586,7 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun #pragma mark - select country delegate -- (void)didSelectCountry:(NSDictionary *)country{ +- (void)didSelectCountry:(NSDictionary *)country { UIRoundBorderedButton *phoneButton = [self findButton:ViewElement_PhoneButton]; [phoneButton setTitle:[country objectForKey:@"name"] forState:UIControlStateNormal]; UIAssistantTextField* countryCodeField = [self findTextField:ViewElement_PhoneCC]; @@ -1541,4 +1595,23 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun [self shouldEnableNextButton]; } +-(void)qrCodeFound:(NSNotification *)notif { + if ([notif.userInfo count] == 0){ + return; + } + [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneQRCodeFound object:nil]; + dispatch_async(dispatch_get_main_queue(), ^{ + self.urlLabel.text = [notif.userInfo objectForKey:@"qrcode"]; + }); + if ([historyViews count] > 0) { + if (currentView == _qrCodeView) { + UIView *view = [historyViews lastObject]; + [historyViews removeLastObject]; + [self changeView:view back:TRUE animation:TRUE]; + } else { + [self changeView:_welcomeView back:TRUE animation:TRUE]; + } + } +} + @end diff --git a/Classes/Base.lproj/AssistantViewScreens.xib b/Classes/Base.lproj/AssistantViewScreens.xib index 5d2c6dc86..119ccd336 100644 --- a/Classes/Base.lproj/AssistantViewScreens.xib +++ b/Classes/Base.lproj/AssistantViewScreens.xib @@ -1,13 +1,12 @@ - + - + - @@ -22,6 +21,7 @@ + @@ -31,9 +31,12 @@ + + + @@ -338,7 +341,7 @@ - + @@ -359,7 +362,7 @@ - + @@ -389,7 +392,7 @@ - + @@ -418,7 +421,7 @@ diff --git a/Classes/LinphoneUI/Base.lproj/UIChatBubbleTextCell.xib b/Classes/LinphoneUI/Base.lproj/UIChatBubbleTextCell.xib index f9eca9b79..d268ae5b5 100644 --- a/Classes/LinphoneUI/Base.lproj/UIChatBubbleTextCell.xib +++ b/Classes/LinphoneUI/Base.lproj/UIChatBubbleTextCell.xib @@ -1,11 +1,11 @@ - + - + diff --git a/Classes/LinphoneUI/Base.lproj/UIChatCell.xib b/Classes/LinphoneUI/Base.lproj/UIChatCell.xib index fe2cac6ad..1a9c2b747 100644 --- a/Classes/LinphoneUI/Base.lproj/UIChatCell.xib +++ b/Classes/LinphoneUI/Base.lproj/UIChatCell.xib @@ -1,8 +1,12 @@ - - + + + + + - + + @@ -11,6 +15,7 @@ + @@ -29,7 +34,7 @@ - + - - + - + + + + + + + + + @@ -77,7 +89,8 @@ - - + + + diff --git a/Classes/LinphoneUI/Base.lproj/UIChatConversationImdnTableViewCell.xib b/Classes/LinphoneUI/Base.lproj/UIChatConversationImdnTableViewCell.xib index 92b814d08..90596f434 100644 --- a/Classes/LinphoneUI/Base.lproj/UIChatConversationImdnTableViewCell.xib +++ b/Classes/LinphoneUI/Base.lproj/UIChatConversationImdnTableViewCell.xib @@ -1,11 +1,11 @@ - + - + @@ -25,18 +25,18 @@ - +