Commit 5dfbd6f2 authored by Anthony Léonard's avatar Anthony Léonard Committed by Adrien Béraud

account: add import-by-file ui in link wizard

The ability to link to an account by using an archive file is
introduced in the wizard dialog. A button is added to chose an archive
file instead of downloading it from the DHT.

Change-Id: I3129ee1c9f1fd2fb69845fdbeb4d7858e81af366
Reviewed-by: Kateryna Kostiuk's avatarKateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
parent 7132a0dc
......@@ -53,7 +53,15 @@
__unsafe_unretained IBOutlet NSView* errorContainer;
__unsafe_unretained IBOutlet NSTextField* pinTextField;
__unsafe_unretained IBOutlet NSButton* fileButton;
__unsafe_unretained IBOutlet NSSecureTextField* passwordTextField;
__unsafe_unretained IBOutlet NSButton* linkButton;
NSString *fileButtonTitleBackup;
Account* accountToCreate;
NSURL* backupFile;
NSTimer* errorTimer;
QMetaObject::Connection stateChanged;
}
......@@ -73,6 +81,12 @@
[initialContainer setHidden:YES];
[loadingContainer setHidden:YES];
[errorContainer setHidden:YES];
[fileButton setTitle:fileButtonTitleBackup];
backupFile = nil;
[pinTextField setStringValue:@""];
[pinTextField setEnabled:YES];
[linkButton setEnabled:NO];
[passwordTextField setStringValue:@""];
}
- (void)show
......@@ -81,6 +95,7 @@
[initialContainer setHidden:YES];
[loadingContainer setHidden:YES];
[errorContainer setHidden:YES];
fileButtonTitleBackup = [fileButton title];
}
- (void)showError
......@@ -109,7 +124,10 @@
profile->save();
}
accountToCreate = AccountModel::instance().add(QString::fromNSString(NSFullUserName()), Account::Protocol::RING);
accountToCreate->setArchivePin(QString::fromNSString(self.pinValue));
if (backupFile == nil)
accountToCreate->setArchivePin(QString::fromNSString(self.pinValue));
else
accountToCreate->setArchivePath(QString::fromLocal8Bit([backupFile fileSystemRepresentation]));
accountToCreate->setArchivePassword(QString::fromNSString(self.passwordValue));
[self setCallback];
......@@ -126,7 +144,25 @@
- (IBAction)back:(id)sender
{
[self deleteAccount];
[self show];
[self goToStepOne:sender];
}
- (IBAction)pickBackupFile:(id)sender
{
NSOpenPanel* filePicker = [NSOpenPanel openPanel];
[filePicker setCanChooseFiles:YES];
[filePicker setCanChooseDirectories:NO];
[filePicker setAllowsMultipleSelection:NO];
if ([filePicker runModal] == NSFileHandlingPanelOKButton) {
if ([[filePicker URLs] count] == 1) {
backupFile = [[filePicker URLs] objectAtIndex:0];
[fileButton setTitle:[backupFile lastPathComponent]];
[pinTextField setEnabled:NO];
[pinTextField setStringValue:@""];
[linkButton setEnabled:YES];
}
}
}
/**
......
......@@ -8,11 +8,14 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="RingWizardLinkAccountVC">
<connections>
<outlet property="createButton" destination="xmI-fH-GpH" id="VnH-tA-YA2"/>
<outlet property="errorContainer" destination="B0P-LC-JmW" id="lKa-Nb-o79"/>
<outlet property="fileButton" destination="gR3-2L-BlK" id="9CB-3U-Izb"/>
<outlet property="firstStepContainer" destination="uuC-qZ-khm" id="CwE-K0-5L5"/>
<outlet property="initialContainer" destination="jR6-WY-o19" id="zJs-xD-OjK"/>
<outlet property="linkButton" destination="xmI-fH-GpH" id="pWU-MH-4Up"/>
<outlet property="loadingContainer" destination="PQA-fA-Rio" id="Vgf-yn-jFS"/>
<outlet property="passwordTextField" destination="VeW-tY-k3K" id="gGe-V6-tzm"/>
<outlet property="pinTextField" destination="BFR-6z-UlF" id="bZs-kY-zUW"/>
<outlet property="progressBar" destination="uxb-PD-AaW" id="r6R-U9-Kf4"/>
<outlet property="view" destination="kG1-xB-0op" id="gnN-lQ-sTg"/>
</connections>
......@@ -20,14 +23,14 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="kG1-xB-0op">
<rect key="frame" x="0.0" y="0.0" width="355" height="222"/>
<rect key="frame" x="0.0" y="0.0" width="355" height="278"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<view translatesAutoresizingMaskIntoConstraints="NO" id="B0P-LC-JmW">
<rect key="frame" x="0.0" y="0.0" width="355" height="222"/>
<rect key="frame" x="0.0" y="0.0" width="355" height="278"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Hwa-xK-TuM">
<rect key="frame" x="-2" y="103" width="359" height="17"/>
<rect key="frame" x="-2" y="131" width="359" height="17"/>
<textFieldCell key="cell" controlSize="mini" sendsActionOnEndEditing="YES" alignment="center" title="An error occured, please check your password and pin." id="DyG-SJ-U1Q">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
......@@ -60,10 +63,10 @@ Gw
</constraints>
</view>
<view translatesAutoresizingMaskIntoConstraints="NO" id="PQA-fA-Rio">
<rect key="frame" x="0.0" y="0.0" width="355" height="222"/>
<rect key="frame" x="0.0" y="0.0" width="355" height="278"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="80Z-XU-adp">
<rect key="frame" x="6" y="74" width="344" height="17"/>
<rect key="frame" x="6" y="102" width="344" height="17"/>
<constraints>
<constraint firstAttribute="width" constant="340" id="OcO-zL-LBK"/>
</constraints>
......@@ -74,7 +77,7 @@ Gw
</textFieldCell>
</textField>
<progressIndicator wantsLayer="YES" maxValue="100" indeterminate="YES" style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="uxb-PD-AaW">
<rect key="frame" x="130" y="131" width="96" height="32"/>
<rect key="frame" x="130" y="159" width="96" height="32"/>
<constraints>
<constraint firstAttribute="width" constant="96" id="QHN-gm-GxV"/>
</constraints>
......@@ -88,10 +91,10 @@ Gw
</constraints>
</view>
<view translatesAutoresizingMaskIntoConstraints="NO" id="jR6-WY-o19" userLabel="Second step">
<rect key="frame" x="0.0" y="0.0" width="355" height="222"/>
<rect key="frame" x="0.0" y="0.0" width="355" height="278"/>
<subviews>
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BFR-6z-UlF">
<rect key="frame" x="78" y="153" width="200" height="22"/>
<rect key="frame" x="78" y="209" width="200" height="22"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="200" id="ql3-eF-0Q3"/>
</constraints>
......@@ -110,7 +113,7 @@ Gw
</connections>
</textField>
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VeW-tY-k3K" customClass="NSSecureTextField">
<rect key="frame" x="78" y="94" width="200" height="22"/>
<rect key="frame" x="78" y="102" width="200" height="22"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="200" id="EQr-I3-bWf"/>
<constraint firstAttribute="width" constant="200" id="XLF-Bw-hQ5"/>
......@@ -130,7 +133,7 @@ Gw
</connections>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Nms-13-N3F">
<rect key="frame" x="76" y="185" width="198" height="17"/>
<rect key="frame" x="76" y="241" width="198" height="17"/>
<constraints>
<constraint firstAttribute="width" constant="194" id="dTT-oe-Tym"/>
</constraints>
......@@ -141,7 +144,7 @@ Gw
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AGs-mP-zJd">
<rect key="frame" x="76" y="126" width="220" height="17"/>
<rect key="frame" x="76" y="134" width="220" height="17"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="200" id="3tj-c0-BEv"/>
</constraints>
......@@ -151,6 +154,24 @@ Gw
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tMy-fd-gBJ">
<rect key="frame" x="164" y="187" width="27" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="OR" id="1NY-Yu-wH1">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="gR3-2L-BlK" userLabel="File button">
<rect key="frame" x="86" y="154" width="184" height="32"/>
<buttonCell key="cell" type="push" title="Pick an account archive" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="XJE-cy-nfQ">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="pickBackupFile:" target="-2" id="Qzv-2L-2Ez"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xmI-fH-GpH">
<rect key="frame" x="261" y="13" width="80" height="32"/>
<constraints>
......@@ -197,22 +218,26 @@ Gw
<constraint firstItem="BFR-6z-UlF" firstAttribute="top" secondItem="Nms-13-N3F" secondAttribute="bottom" constant="10" id="9rR-Bz-IV5"/>
<constraint firstItem="BFR-6z-UlF" firstAttribute="centerX" secondItem="jR6-WY-o19" secondAttribute="centerX" id="B1d-wB-vV0"/>
<constraint firstAttribute="bottom" secondItem="oxG-mq-q2J" secondAttribute="bottom" constant="20" id="BVR-t4-MeU"/>
<constraint firstItem="gR3-2L-BlK" firstAttribute="top" secondItem="tMy-fd-gBJ" secondAttribute="bottom" constant="5" id="DN2-bb-LGV"/>
<constraint firstItem="VeW-tY-k3K" firstAttribute="leading" secondItem="AGs-mP-zJd" secondAttribute="leading" id="DpC-se-5c3"/>
<constraint firstItem="AGs-mP-zJd" firstAttribute="top" secondItem="BFR-6z-UlF" secondAttribute="bottom" constant="10" id="Mlp-x7-UId"/>
<constraint firstItem="tMy-fd-gBJ" firstAttribute="centerX" secondItem="jR6-WY-o19" secondAttribute="centerX" id="Fxo-hk-7Ft"/>
<constraint firstItem="AGs-mP-zJd" firstAttribute="top" secondItem="gR3-2L-BlK" secondAttribute="bottom" constant="10" id="Mlp-x7-UId"/>
<constraint firstAttribute="bottom" secondItem="xmI-fH-GpH" secondAttribute="bottom" constant="20" id="ONV-r0-v26"/>
<constraint firstItem="Nms-13-N3F" firstAttribute="top" secondItem="jR6-WY-o19" secondAttribute="top" constant="20" id="PM0-u5-7XA"/>
<constraint firstItem="VeW-tY-k3K" firstAttribute="top" secondItem="AGs-mP-zJd" secondAttribute="bottom" constant="10" id="Qo1-zb-2YI"/>
<constraint firstItem="xmI-fH-GpH" firstAttribute="leading" secondItem="oxG-mq-q2J" secondAttribute="trailing" constant="12" id="ZS7-xm-STi"/>
<constraint firstItem="tMy-fd-gBJ" firstAttribute="top" secondItem="BFR-6z-UlF" secondAttribute="bottom" constant="5" id="fm7-Hx-HHM"/>
<constraint firstAttribute="trailing" secondItem="xmI-fH-GpH" secondAttribute="trailing" constant="20" id="kub-6B-85y"/>
<constraint firstItem="gR3-2L-BlK" firstAttribute="centerX" secondItem="BFR-6z-UlF" secondAttribute="centerX" id="p3N-zJ-HWN"/>
<constraint firstItem="VeW-tY-k3K" firstAttribute="leading" secondItem="BFR-6z-UlF" secondAttribute="leading" id="qVJ-Qu-dRy"/>
<constraint firstItem="VeW-tY-k3K" firstAttribute="trailing" secondItem="BFR-6z-UlF" secondAttribute="trailing" id="szw-nO-R5J"/>
</constraints>
</view>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="uuC-qZ-khm" userLabel="First step">
<rect key="frame" x="0.0" y="0.0" width="355" height="222"/>
<rect key="frame" x="0.0" y="0.0" width="355" height="278"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3JH-zM-ysj">
<rect key="frame" x="26" y="122" width="304" height="55"/>
<rect key="frame" x="26" y="178" width="304" height="55"/>
<constraints>
<constraint firstAttribute="width" constant="300" id="28q-2A-cNP"/>
<constraint firstAttribute="height" constant="55" id="YJg-LO-EmI"/>
......@@ -225,7 +250,7 @@ Gw
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="C9D-AI-hDL">
<rect key="frame" x="13" y="97" width="149" height="17"/>
<rect key="frame" x="13" y="153" width="149" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="2. Generate a PIN code" id="GfW-ah-8U1">
<font key="font" metaFont="systemSemibold" size="13"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
......@@ -233,7 +258,7 @@ Gw
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4HV-K6-7nz">
<rect key="frame" x="14" y="185" width="316" height="17"/>
<rect key="frame" x="14" y="241" width="316" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="1. Grab a device with the account you want to use" id="HcT-yD-KVo">
<font key="font" metaFont="systemSemibold" size="13"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
......@@ -267,7 +292,7 @@ Gw
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2hL-HI-nb6">
<rect key="frame" x="25" y="55" width="304" height="34"/>
<rect key="frame" x="25" y="111" width="304" height="34"/>
<constraints>
<constraint firstAttribute="width" constant="300" id="UJk-c7-Edh"/>
</constraints>
......@@ -312,7 +337,7 @@ Gw
<constraint firstItem="jR6-WY-o19" firstAttribute="top" secondItem="kG1-xB-0op" secondAttribute="top" id="rUX-4w-KaX"/>
<constraint firstItem="B0P-LC-JmW" firstAttribute="bottom" secondItem="jR6-WY-o19" secondAttribute="bottom" id="vlI-JJ-jbZ"/>
</constraints>
<point key="canvasLocation" x="340.5" y="373"/>
<point key="canvasLocation" x="340.5" y="401"/>
</customView>
</objects>
</document>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment