add support of qrcode reading for provisioning profile [Switch submodule branch]

This commit is contained in:
Benjamin Verdier 2018-06-19 15:45:16 +02:00
parent 142977ac19
commit 7ea78c8952
10 changed files with 107 additions and 24 deletions

3
.gitmodules vendored
View file

@ -117,3 +117,6 @@
[submodule "submodules/externals/soci"]
path = submodules/externals/soci
url = git://git.linphone.org/soci
[submodule "submodules/externals/zxing-cpp"]
path = submodules/externals/zxing-cpp
url = git://git.linphone.org/zxing-cpp.git

View file

@ -21,6 +21,7 @@
#import "UICompositeView.h"
#import "TPKeyboardAvoidingScrollView.h"
#import "PhoneMainView.h"
#import <AVFoundation/AVFoundation.h>
@interface AssistantView : UIViewController <UITextFieldDelegate, UICompositeViewDelegate> {
@ -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,7 @@
@property (weak, nonatomic) IBOutlet UILabel *activationSMSText;
@property (weak, nonatomic) IBOutlet UILabel *accountLabel;
@property (weak, nonatomic) IBOutlet UITextField *urlLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *createAccountNextButtonPositionConstraint;
+ (NSString *)StringForXMLRPCError:(const char *)err;
@ -92,6 +95,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;

View file

@ -28,6 +28,7 @@
#import "PhoneMainView.h"
#import "UIAssistantTextField.h"
#import "UITextField+DoneButton.h"
#import "LinphoneAppDelegate.h"
typedef enum _ViewElement {
ViewElement_Username = 100,
@ -134,6 +135,8 @@ static UICompositeViewDescription *compositeDescription = nil;
[_contentView setContentSize:frame.size];
[_contentView contentSizeToFit];
_qrCodeView.frame = [[UIScreen mainScreen] bounds];
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
@ -474,6 +477,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) {
@ -1396,6 +1406,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 +1562,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 +1585,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 +1594,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

View file

@ -30,9 +30,11 @@
<outlet property="loginView" destination="56" id="bJH-N8-uPi"/>
<outlet property="phoneLabel" destination="ZSJ-Lv-n60" id="5Qi-xR-wyK"/>
<outlet property="phoneTitle" destination="rAy-0V-sqv" id="MZq-EF-6HF"/>
<outlet property="qrCodeView" destination="Z2R-SD-yFJ" id="dcs-rK-HgK"/>
<outlet property="remoteProvisioningLoginView" destination="xVK-hL-6pe" id="pKL-9M-Vsa"/>
<outlet property="remoteProvisioningView" destination="Zuh-Sd-pcd" id="3pa-2M-5Xq"/>
<outlet property="subtileLabel_useLinphoneAccount" destination="4n3-ZD-KVi" id="8d9-0f-2Vi"/>
<outlet property="urlLabel" destination="Ffg-Of-xyh" id="IhC-hf-1OG"/>
<outlet property="welcomeView" destination="33" id="46a-AR-5mN"/>
</connections>
</placeholder>
@ -1347,7 +1349,7 @@ Once it is done, come back here and click on the button.</string>
<action selector="onRemoteProvisioningDownloadClick:" destination="-1" eventType="touchUpInside" id="6yF-1w-Hpa"/>
</connections>
</button>
<button opaque="NO" tag="130" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2T9-bt-FHD" userLabel="qrcodeButton" customClass="UIRoundBorderedButton">
<button opaque="NO" tag="130" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2T9-bt-FHD" userLabel="qrcodeButton" customClass="UIRoundBorderedButton">
<rect key="frame" x="38" y="219" width="299" height="40"/>
<accessibility key="accessibilityConfiguration" label="Fetch and apply">
<bool key="isElement" value="YES"/>
@ -1364,7 +1366,7 @@ Once it is done, come back here and click on the button.</string>
</state>
<state key="highlighted" backgroundImage="color_F.png"/>
<connections>
<action selector="onRemoteProvisioningDownloadClick:" destination="-1" eventType="touchUpInside" id="5CK-Mb-McE"/>
<action selector="onLaunchQRCodeView:" destination="-1" eventType="touchUpInside" id="i1k-Su-mAZ"/>
</connections>
</button>
</subviews>
@ -1552,6 +1554,12 @@ Once it is done, come back here and click on the button.</string>
<action selector="onLinkTap:" destination="-1" id="xXJ-65-gxy"/>
</connections>
</tapGestureRecognizer>
<view contentMode="scaleToFill" id="Z2R-SD-yFJ" userLabel="qrCodeView">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<point key="canvasLocation" x="1918" y="554"/>
</view>
</objects>
<resources>
<image name="color_F.png" width="2" height="2"/>

View file

@ -39,6 +39,7 @@
@property PKPushRegistry* voipRegistry;
@property ProviderDelegate *del;
@property BOOL alreadyRegisteredForNotification;
@property BOOL onlyPortrait;
@end

View file

@ -44,6 +44,7 @@
startedInBackground = FALSE;
}
_alreadyRegisteredForNotification = false;
_onlyPortrait = FALSE;
return self;
[[UIApplication sharedApplication] setDelegate:self];
}
@ -218,17 +219,6 @@
actions:[NSArray arrayWithObjects:act_confirm, act_deny, nil]
intentIdentifiers:[[NSMutableArray alloc] init]
options:UNNotificationCategoryOptionCustomDismissAction];
// App version verification
UNNotificationAction *act_go_to_URL = [UNNotificationAction actionWithIdentifier:@"Download"
title:NSLocalizedString(@"Download", nil)
options:UNNotificationActionOptionNone];
UNNotificationCategory *version_verif =
[UNNotificationCategory categoryWithIdentifier:@"version_verif"
actions:[NSArray arrayWithObjects:act_go_to_URL, nil]
intentIdentifiers:[[NSMutableArray alloc] init]
options:UNNotificationCategoryOptionCustomDismissAction];
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge)
@ -238,7 +228,7 @@
LOGD(error.description);
}];
NSSet *categories = [NSSet setWithObjects:cat_call, cat_msg, video_call, cat_zrtp, version_verif, nil];
NSSet *categories = [NSSet setWithObjects:cat_call, cat_msg, video_call, cat_zrtp, nil];
[[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:categories];
}
@ -674,10 +664,6 @@ didInvalidatePushTokenForType:(NSString *)type {
}];
} else if ([response.notification.request.content.categoryIdentifier isEqual:@"lime"]) {
return;
} else if ([response.notification.request.content.categoryIdentifier isEqual:@"version_verif"]) {
NSString *url = [response.notification.request.content.userInfo objectForKey:@"url"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
return;
} else { // Missed call
[PhoneMainView.instance changeCurrentView:HistoryListView.compositeViewDescription];
}
@ -849,14 +835,13 @@ didInvalidatePushTokenForType:(NSString *)type {
#pragma mark - Prevent ImagePickerView from rotating
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
if ([[(PhoneMainView*)self.window.rootViewController currentView] equal:ImagePickerView.compositeViewDescription])
if ([[(PhoneMainView*)self.window.rootViewController currentView] equal:ImagePickerView.compositeViewDescription] || _onlyPortrait)
{
//Prevent rotation of camera
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
return UIInterfaceOrientationMaskPortrait;
}
else return UIInterfaceOrientationMaskAllButUpsideDown;
} else return UIInterfaceOrientationMaskAllButUpsideDown;
}
@end

View file

@ -56,6 +56,7 @@ extern NSString *const kLinphoneNotifyPresenceReceivedForUriOrTel;
extern NSString *const kLinphoneCallEncryptionChanged;
extern NSString *const kLinphoneFileTransferSendUpdate;
extern NSString *const kLinphoneFileTransferRecvUpdate;
extern NSString *const kLinphoneQRCodeFound;
typedef enum _NetworkType {
network_none = 0,

View file

@ -76,6 +76,7 @@ NSString *const kLinphoneNotifyPresenceReceivedForUriOrTel = @"LinphoneNotifyPre
NSString *const kLinphoneCallEncryptionChanged = @"LinphoneCallEncryptionChanged";
NSString *const kLinphoneFileTransferSendUpdate = @"LinphoneFileTransferSendUpdate";
NSString *const kLinphoneFileTransferRecvUpdate = @"LinphoneFileTransferRecvUpdate";
NSString *const kLinphoneQRCodeFound = @"LinphoneQRCodeFound";
const int kLinphoneAudioVbrCodecDefaultBitrate = 36; /*you can override this from linphonerc or linphonerc-factory*/
@ -1416,6 +1417,12 @@ void linphone_iphone_version_update_check_result_received (LinphoneCore *lc, Lin
[PhoneMainView.instance presentViewController:versVerifView animated:YES completion:nil];
}
void linphone_iphone_qr_code_found(LinphoneCore *lc, const char *result) {
NSDictionary *eventDic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:result encoding:[NSString defaultCStringEncoding]] forKey:@"qrcode"];
LOGD(@"QRCODE FOUND");
[NSNotificationCenter.defaultCenter postNotificationName:kLinphoneQRCodeFound object:nil userInfo:eventDic];
}
#pragma mark - Message composition start
- (void)alertLIME:(LinphoneChatRoom *)room {
NSString *title = NSLocalizedString(@"LIME warning", nil);
@ -1988,6 +1995,7 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
linphone_core_cbs_set_chat_room_state_changed(cbs, linphone_iphone_chatroom_state_changed);
linphone_core_cbs_set_version_update_check_result_received(cbs, linphone_iphone_version_update_check_result_received);
linphone_core_cbs_set_user_data(cbs, (__bridge void *)(self));
linphone_core_cbs_set_qrcode_found(cbs, linphone_iphone_qr_code_found);
theLinphoneCore = linphone_factory_create_core_with_config(factory, cbs, _configDb);
// Let the core handle cbs

@ -1 +1 @@
Subproject commit 68f19de842824573dd075a4ec41483930b8de325
Subproject commit 01c40162d1119a562f965b03576ddff241b5483d

1
submodules/externals/zxing-cpp vendored Submodule

@ -0,0 +1 @@
Subproject commit 8906fb7b243fa455fd9b091e4ac611536b2dbba4