multi-device: add account migration

Prompt user to add a password for each of his Ring accounts in order to
use the new multi-device system.

Change-Id: I7a75b04330eabc3d229f8fd613cad69ed8d66eb5
Tuleap: #960
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5ce8704..4d93f9a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -144,6 +144,8 @@
    src/AccDevicesVC.h
    src/ExportPasswordWC.mm
    src/ExportPasswordWC.h
+   src/MigrateRingAccountsWC.mm
+   src/MigrateRingAccountsWC.h
 )
 
 SET(ringclient_BACKENDS
@@ -201,6 +203,7 @@
    CertificateWindow
    PathPasswordWindow
    ExportPasswordWindow
+   MigrateRingAccountsWindow
    PersonLinker
    Broker
    Conversation
diff --git a/src/LoadingWCProtocol.h b/src/LoadingWCProtocol.h
new file mode 100644
index 0000000..83ae46d
--- /dev/null
+++ b/src/LoadingWCProtocol.h
@@ -0,0 +1,44 @@
+/*
+ *  Copyright (C) 2015-2016 Savoir-faire Linux Inc.
+ *  Author: Loïc Siret <loic.siret@savoirfairelinux.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
+ */
+
+#import <Foundation/Foundation.h>
+#import "LoadingWCDelegate.h"
+@protocol LoadingWCProtocol <NSObject>
+
+
+- (id)initWithDelegate:(id <LoadingWCDelegate>) del
+            actionCode:(NSInteger) code;
+- (IBAction)completeAction:(id)sender;
+- (IBAction)cancelPressed:(id)sender;
+@optional
+
+/*
+ * Display an error message to the user
+ */
+- (void)showError:(NSString*) error;
+/*
+ * Show progress during action completion
+ */
+- (void)showLoading;
+/*
+ * Show final state after action completion
+ */
+- (void)showFinal;
+
+@end
diff --git a/src/MigrateRingAccountsWC.h b/src/MigrateRingAccountsWC.h
new file mode 100644
index 0000000..31db7a8
--- /dev/null
+++ b/src/MigrateRingAccountsWC.h
@@ -0,0 +1,62 @@
+/*
+ *  Copyright (C) 2016 Savoir-faire Linux Inc.
+ *  Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+//LRC
+#import <account.h>
+
+//RING
+#import "LoadingWCProtocol.h"
+#import "LoadingWCDelegate.h"
+#import "AbstractLoadingWC.h"
+
+@protocol MigrateRingAccountsDelegate <LoadingWCDelegate>
+
+-(void) migrationDidCompleteWithError;
+-(void) migrationDidComplete;
+
+@end
+
+@interface MigrateRingAccountsWC : AbstractLoadingWC <LoadingWCProtocol>
+
+/**
+ * password string contained in passwordField.
+ */
+@property (retain) NSString* password;
+
+/**
+ * passwordConfirmation string contained in passwordConfirmationField.
+ */
+@property (retain) NSString* passwordConfirmation;
+
+/**
+ * computed properties calculated by password string contained in
+ * passwordField and passwordCOnfirmation string contained
+ * inpasswordConfirmationField
+ * This is a KVO method to bind the text with the OK Button
+ * if password.length is > 0 AND passwordConfirmation.length > 0
+ * AND password isEqualsToString passwordCOnfirmationbutton is enabled,
+ * otherwise disabled
+ */
+@property (readonly) BOOL validatePasswords;
+
+@property Account* account;
+
+@end
diff --git a/src/MigrateRingAccountsWC.mm b/src/MigrateRingAccountsWC.mm
new file mode 100644
index 0000000..0e49e11
--- /dev/null
+++ b/src/MigrateRingAccountsWC.mm
@@ -0,0 +1,185 @@
+/*
+ *  Copyright (C) 2016 Savoir-faire Linux Inc.
+ *  Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
+ */
+
+#import "MigrateRingAccountsWC.h"
+
+//LRC
+#import <accountmodel.h>
+
+//RING
+#import "views/ITProgressIndicator.h"
+
+@interface MigrateRingAccountsWC() <NSTextFieldDelegate>{
+    __unsafe_unretained IBOutlet NSSecureTextField* passwordField;
+    __unsafe_unretained IBOutlet NSSecureTextField* passwordConfirmField;
+    __unsafe_unretained IBOutlet NSTextField* infoField;
+    __unsafe_unretained IBOutlet NSTextField* errorField;
+    __unsafe_unretained IBOutlet ITProgressIndicator* progressIndicator;
+}
+
+- (IBAction)onClickComplete:(id)sender;
+@end
+
+@implementation MigrateRingAccountsWC{
+    struct {
+        unsigned int didComplete:1;
+        unsigned int didCompleteWithError:1;
+    } delegateRespondsTo;
+}
+
+NSTimer* errorTimer;
+QMetaObject::Connection stateChanged;
+
+#pragma mark - Initialise / Setters
+- (id)initWithDelegate:(id <MigrateRingAccountsDelegate>) del actionCode:(NSInteger) code
+{
+    return [super initWithWindowNibName:@"MigrateRingAccountsWindow" delegate:del actionCode:code];
+}
+
+- (void) awakeFromNib{
+    [self setInfoMessageForAccount];
+}
+
+- (void)setDelegate:(id <MigrateRingAccountsDelegate>)aDelegate
+{
+    if (super.delegate != aDelegate) {
+        [super setDelegate: aDelegate];
+        delegateRespondsTo.didCompleteWithError = [self.delegate respondsToSelector:@selector(migrationDidCompleteWithError)];
+        delegateRespondsTo.didComplete = [self.delegate respondsToSelector:@selector(migrationDidComplete)];
+    }
+}
+
+- (void) setAccount:(Account *)aAccount
+{
+    _account = aAccount;
+}
+
+- (void) setInfoMessageForAccount
+{
+    NSMutableAttributedString* infoMessage = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"The following account needs to be migrated to the new Ring account format:",@"Text shown to the user")];
+    [infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]];
+    [infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"Alias : ",@"Text shown to the user")]];
+    const CGFloat fontSize = 13;
+    NSDictionary *attrs = @{
+                            NSFontAttributeName:[NSFont boldSystemFontOfSize:fontSize]
+                            };
+    [infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:self.account->alias().toNSString() attributes:attrs]];
+    [infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]];
+    [infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"ID : ",@"Text shown to the user")]];
+    [infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@(self.account->id().constData()) attributes:attrs]];
+    [infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]];
+    [infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"To proceed with the migration, you must choose a password for your account. This password will be used to encrypt your master key. It will be required for adding new devices to your Ring account. If you are not ready to choose a password, you may close Ring and resume the migration later.",@"Text shown to the user")]];
+    [infoField setAttributedStringValue:infoMessage];
+}
+
+
+- (void) showError:(NSString*) errorMessage
+{
+    [errorField setStringValue:errorMessage];
+    [super showError];
+}
+
+- (void)showLoading
+{
+    [progressIndicator setNumberOfLines:30];
+    [progressIndicator setWidthOfLine:2];
+    [progressIndicator setLengthOfLine:5];
+    [progressIndicator setInnerMargin:20];
+    [super showLoading];
+}
+
+#pragma mark - Events Handlers
+- (IBAction)removeAccount:(id)sender
+{
+    AccountModel::instance().remove(self.account);
+    AccountModel::instance().save();
+    [self cancelPressed:sender];
+}
+
+- (IBAction)startMigration:(NSButton *)sender
+{
+    if (![self validatePasswords]) {
+        [self showError:NSLocalizedString(@"Password and confirmation mismatch.",@"Text show to the user when password didn't match")];
+    } else {
+        [self showLoading];
+        errorTimer = [NSTimer scheduledTimerWithTimeInterval:30
+                                                      target:self
+                                                    selector:@selector(didCompleteWithError) userInfo:nil
+                                                     repeats:NO];
+        stateChanged = QObject::connect(
+                                        self.account, &Account::stateChanged,
+                                        [=](Account::RegistrationState state){
+                                            switch(state){
+                                                case Account::RegistrationState::READY:
+                                                case Account::RegistrationState::TRYING:
+                                                case Account::RegistrationState::UNREGISTERED:{
+                                                    self.account<< Account::EditAction::RELOAD;
+                                                    QObject::disconnect(stateChanged);
+                                                    [self didComplete];
+                                                    break;
+                                                }
+                                                case Account::RegistrationState::ERROR:
+                                                case Account::RegistrationState::INITIALIZING:
+                                                case Account::RegistrationState::COUNT__:{
+                                                    //DO Nothing
+                                                    break;
+                                                }
+                                            }
+                                        });
+        self.account->setArchivePassword(QString::fromNSString(self.password));
+        self.account->performAction(Account::EditAction::SAVE);
+    }
+}
+
+- (BOOL)validatePasswords
+{
+    BOOL result = (self.password.length != 0 && [self.password isEqualToString:self.passwordConfirmation]);
+    NSLog(@"ValidatesPasswords : %s", result ? "true" : "false");
+    return result;
+}
+
++ (NSSet *)keyPathsForValuesAffectingValidatePasswords
+{
+    return [NSSet setWithObjects:@"password", @"passwordConfirmation", nil];
+}
+
+
+#pragma mark - Delegates
+- (void)didComplete
+{
+    [errorTimer invalidate];
+    errorTimer = nil;
+    [self showFinal];
+}
+
+- (void)onClickComplete:(id)sender
+{
+    [self cancelPressed:sender];
+    if (delegateRespondsTo.didComplete)
+        [((id<MigrateRingAccountsDelegate>)self.delegate) migrationDidComplete];
+}
+
+
+- (void)didCompleteWithError
+{
+    [self showError:NSLocalizedString(@"Failed to migrate your account. You can retry by pressing Ok or delete your account.",@"Error message shown to user when it is impossible to migrate account")];
+}
+
+
+@end
diff --git a/src/RingWindowController.mm b/src/RingWindowController.mm
index 01417ed..06d866c 100644
--- a/src/RingWindowController.mm
+++ b/src/RingWindowController.mm
@@ -31,15 +31,22 @@
 #import <call.h>
 #import <recentmodel.h>
 
+// Ring
 #import "AppDelegate.h"
 #import "Constants.h"
 #import "CurrentCallVC.h"
+#import "MigrateRingAccountsWC.h"
 #import "ConversationVC.h"
-
 #import "PreferencesWC.h"
 #import "views/IconButton.h"
 #import "views/NSColor+RingTheme.h"
 
+@interface RingWindowController () <MigrateRingAccountsDelegate>
+
+@property (retain) MigrateRingAccountsWC* migrateWC;
+
+@end
+
 @implementation RingWindowController {
 
     __unsafe_unretained IBOutlet NSLayoutConstraint* centerYQRCodeConstraint;
@@ -55,6 +62,7 @@
     ConversationVC* offlineVC;
 }
 
+QMetaObject::Connection accountUpdate;
 static NSString* const kPreferencesIdentifier = @"PreferencesIdentifier";
 
 - (void)windowDidLoad {
@@ -74,21 +82,18 @@
     [currentCallVC initFrame];
     [offlineVC initFrame];
 
-    // Fresh run, we need to make sure RingID appears
-    [self updateRingID];
-    [shareButton sendActionOn:NSLeftMouseDownMask];
-
-    [self connect];
+    [self checkAccountsToMigrate];
 }
 
 - (void) connect
 {
     // Update Ring ID label based on account model changes
-    QObject::connect(&AccountModel::instance(),
-                     &AccountModel::dataChanged,
-                     [=] {
-                         [self updateRingID];
-                     });
+    QObject::disconnect(accountUpdate);
+    accountUpdate = QObject::connect(&AccountModel::instance(),
+                                     &AccountModel::dataChanged,
+                                     [=] {
+                                         [self updateRingID];
+                                     });
 
     QObject::connect(RecentModel::instance().selectionModel(),
                      &QItemSelectionModel::currentChanged,
@@ -265,4 +270,46 @@
     [preferencesWC.window makeKeyAndOrderFront:preferencesWC.window];
 }
 
+#pragma mark - Ring account migration
+
+- (void) migrateRingAccount:(Account*) acc
+{
+    self.migrateWC = [[MigrateRingAccountsWC alloc] initWithDelegate:self actionCode:1];
+    self.migrateWC.account = acc;
+#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_9
+    [self.window beginSheet:self.migrateWC.window completionHandler:nil];
+#else
+    [NSApp beginSheet: self.migrateWC.window
+       modalForWindow: self.window
+        modalDelegate: self
+       didEndSelector: nil
+          contextInfo: nil];
+#endif
+}
+
+- (void)checkAccountsToMigrate
+{
+    auto ringList = AccountModel::instance().accountsToMigrate();
+    if (ringList.length() > 0){
+        Account* acc = ringList.value(0);
+        [self migrateRingAccount:acc];
+    } else {
+        // Fresh run, we need to make sure RingID appears
+        [self updateRingID];
+        [shareButton sendActionOn:NSLeftMouseDownMask];
+
+        [self connect];
+    }
+}
+
+- (void)migrationDidComplete
+{
+    [self checkAccountsToMigrate];
+}
+
+- (void)migrationDidCompleteWithError
+{
+    [self checkAccountsToMigrate];
+}
+
 @end
diff --git a/ui/Base.lproj/MigrateRingAccountsWindow.strings b/ui/Base.lproj/MigrateRingAccountsWindow.strings
new file mode 100644
index 0000000..ca1377b
--- /dev/null
+++ b/ui/Base.lproj/MigrateRingAccountsWindow.strings
@@ -0,0 +1,48 @@
+
+/* Class = "NSTextFieldCell"; title = "Account migration completed"; ObjectID = "1ob-x1-u74"; */
+"1ob-x1-u74.title" = "Account migration completed";
+
+/* Class = "NSTextFieldCell"; placeholderString = "RingID"; ObjectID = "859-10-HEb"; */
+"859-10-HEb.placeholderString" = "RingID";
+
+/* Class = "NSTextFieldCell"; title = "The following account needs to be migrated to the new Ring account format:\\n Alias : \\nID:\\n To proceed with the migration, you must choose a password for your account. This password will be used to encrypt your master key. It will be required for adding new devices to your Ring account. If you are not ready to choose a password, you may close Ring and resume the migration later."; ObjectID = "859-10-HEb"; */
+"859-10-HEb.title" = "The following account needs to be migrated to the new Ring account format:\\n Alias : \\nID:\\n To proceed with the migration, you must choose a password for your account. This password will be used to encrypt your master key. It will be required for adding new devices to your Ring account. If your not ready to choose a password, you may close Ring and resume the migration later.";
+
+/* Class = "NSTextFieldCell"; title = "Account migration error"; ObjectID = "8K3-9Z-MKH"; */
+"8K3-9Z-MKH.title" = "Account migration error";
+
+/* Class = "NSTextFieldCell"; title = "Congratulations, your account has been migrated with Success."; ObjectID = "C2l-rz-Gqt"; */
+"C2l-rz-Gqt.title" = "Congratulations, your account has been migrated with Success.";
+
+/* Class = "NSButtonCell"; title = "Delete this account"; ObjectID = "ITE-yD-CTb"; */
+"ITE-yD-CTb.title" = "Delete this account";
+
+/* Class = "NSSecureTextFieldCell"; placeholderString = "Confirm your new password..."; ObjectID = "KuO-oT-zhY"; */
+"KuO-oT-zhY.placeholderString" = "Confirm your new password...";
+
+/* Class = "NSButtonCell"; title = "OK"; ObjectID = "PT7-XI-WDR"; */
+"PT7-XI-WDR.title" = "OK";
+
+/* Class = "NSWindow"; title = "Window"; ObjectID = "QvC-M9-y7g"; */
+"QvC-M9-y7g.title" = "Window";
+
+/* Class = "NSButtonCell"; title = "OK"; ObjectID = "VN1-A3-RIh"; */
+"VN1-A3-RIh.title" = "OK";
+
+/* Class = "NSTextFieldCell"; title = "Confirmation"; ObjectID = "aOa-1q-AZe"; */
+"aOa-1q-AZe.title" = "Confirmation";
+
+/* Class = "NSTextFieldCell"; placeholderString = "error label"; ObjectID = "e7n-Ev-bK7"; */
+"e7n-Ev-bK7.placeholderString" = "error label";
+
+/* Class = "NSButtonCell"; title = "Migrate"; ObjectID = "rW5-Il-5YD"; */
+"rW5-Il-5YD.title" = "Migrate";
+
+/* Class = "NSTextFieldCell"; title = "Password"; ObjectID = "vwh-K9-3O9"; */
+"vwh-K9-3O9.title" = "Password";
+
+/* Class = "NSTextFieldCell"; title = "Account migration required"; ObjectID = "wmv-sA-Mlh"; */
+"wmv-sA-Mlh.title" = "Account migration required";
+
+/* Class = "NSSecureTextFieldCell"; placeholderString = "Password..."; ObjectID = "xqz-Uz-hqU"; */
+"xqz-Uz-hqU.placeholderString" = "Password...";
diff --git a/ui/Base.lproj/MigrateRingAccountsWindow.xib b/ui/Base.lproj/MigrateRingAccountsWindow.xib
new file mode 100644
index 0000000..3cebb71
--- /dev/null
+++ b/ui/Base.lproj/MigrateRingAccountsWindow.xib
@@ -0,0 +1,288 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+    <dependencies>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
+        <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="MigrateRingAccountsWC">
+            <connections>
+                <outlet property="errorContainer" destination="ty1-sj-tT6" id="eEy-Cr-yiw"/>
+                <outlet property="errorField" destination="G1N-th-ZtP" id="OZ1-F7-jN7"/>
+                <outlet property="finalContainer" destination="D9c-cc-43F" id="WCp-fn-u2t"/>
+                <outlet property="infoField" destination="Qx0-KE-jEl" id="ACx-L8-XrX"/>
+                <outlet property="initialContainer" destination="xUT-yB-g8Q" id="RY9-PG-fGI"/>
+                <outlet property="passwordConfirmField" destination="fb6-6f-oqD" id="zo7-JA-tSY"/>
+                <outlet property="passwordField" destination="vej-Z8-dOm" id="2t8-o5-iHa"/>
+                <outlet property="progressContainer" destination="IbM-NP-t4j" id="1tS-X7-u5j"/>
+                <outlet property="progressIndicator" destination="LsP-hk-8Om" id="gdo-uC-Qlu"/>
+                <outlet property="window" destination="QvC-M9-y7g" id="bos-rN-Jgz"/>
+            </connections>
+        </customObject>
+        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+        <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="QvC-M9-y7g">
+            <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
+            <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
+            <rect key="contentRect" x="196" y="240" width="508" height="296"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
+            <view key="contentView" id="EiT-Mj-1SZ">
+                <rect key="frame" x="0.0" y="0.0" width="508" height="296"/>
+                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                <subviews>
+                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="xUT-yB-g8Q" userLabel="Migration Container">
+                        <rect key="frame" x="20" y="20" width="468" height="266"/>
+                        <subviews>
+                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="YR8-e7-f8B">
+                                <rect key="frame" x="-2" y="249" width="472" height="17"/>
+                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Account migration required" id="wmv-sA-Mlh">
+                                    <font key="font" metaFont="systemBold"/>
+                                    <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                                </textFieldCell>
+                            </textField>
+                            <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="Qx0-KE-jEl">
+                                <rect key="frame" x="-2" y="144" width="472" height="85"/>
+                                <textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="justified" placeholderString="RingID" id="859-10-HEb">
+                                    <font key="font" metaFont="system"/>
+                                    <string key="title">The following account needs to be migrated to the new Ring account format:\n Alias : \nID:\n To proceed the migration, you must choose a password for your account. This password will be used to encrypt your master key. It will be required for adding new devices to your Ring account. If your not ready to choose a password, you may close Ring and resume the migration later.</string>
+                                    <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                                </textFieldCell>
+                            </textField>
+                            <secureTextField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vej-Z8-dOm">
+                                <rect key="frame" x="105" y="105" width="243" height="22"/>
+                                <secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" borderStyle="bezel" placeholderString="Password..." drawsBackground="YES" usesSingleLineMode="YES" id="xqz-Uz-hqU">
+                                    <font key="font" metaFont="system"/>
+                                    <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
+                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                    <allowedInputSourceLocales>
+                                        <string>NSAllRomanInputSourcesLocaleIdentifier</string>
+                                    </allowedInputSourceLocales>
+                                </secureTextFieldCell>
+                                <connections>
+                                    <binding destination="-2" name="value" keyPath="self.password" id="WWB-sb-wyk">
+                                        <dictionary key="options">
+                                            <bool key="NSConditionallySetsEditable" value="NO"/>
+                                            <bool key="NSContinuouslyUpdatesValue" value="YES"/>
+                                        </dictionary>
+                                    </binding>
+                                    <outlet property="delegate" destination="-2" id="UEj-AI-SPU"/>
+                                </connections>
+                            </secureTextField>
+                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="bZ5-at-jng">
+                                <rect key="frame" x="-2" y="65" width="83" height="17"/>
+                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Confirmation" id="aOa-1q-AZe">
+                                    <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="oXB-Be-LaB">
+                                <rect key="frame" x="387" y="-7" width="87" height="32"/>
+                                <buttonCell key="cell" type="push" title="Migrate" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="rW5-Il-5YD">
+                                    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                    <font key="font" metaFont="system"/>
+                                    <string key="keyEquivalent" base64-UTF8="YES">
+DQ
+</string>
+                                </buttonCell>
+                                <connections>
+                                    <action selector="startMigration:" target="-2" id="MW5-vm-X5X"/>
+                                    <binding destination="-2" name="enabled" keyPath="self.validatePasswords" id="vyp-i8-Drw"/>
+                                </connections>
+                            </button>
+                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Bcr-Pl-Fz9">
+                                <rect key="frame" x="-2" y="108" width="63" height="17"/>
+                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Password" id="vwh-K9-3O9">
+                                    <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>
+                            <secureTextField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="fb6-6f-oqD" userLabel="Password confirmation">
+                                <rect key="frame" x="105" y="62" width="243" height="22"/>
+                                <secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" borderStyle="bezel" placeholderString="Confirm your new password..." drawsBackground="YES" usesSingleLineMode="YES" id="KuO-oT-zhY">
+                                    <font key="font" metaFont="system"/>
+                                    <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
+                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                    <allowedInputSourceLocales>
+                                        <string>NSAllRomanInputSourcesLocaleIdentifier</string>
+                                    </allowedInputSourceLocales>
+                                </secureTextFieldCell>
+                                <connections>
+                                    <binding destination="-2" name="value" keyPath="self.passwordConfirmation" id="mVZ-rM-3Px">
+                                        <dictionary key="options">
+                                            <bool key="NSContinuouslyUpdatesValue" value="YES"/>
+                                        </dictionary>
+                                    </binding>
+                                    <outlet property="delegate" destination="-2" id="4W6-t5-1uA"/>
+                                </connections>
+                            </secureTextField>
+                        </subviews>
+                        <constraints>
+                            <constraint firstAttribute="trailing" secondItem="Qx0-KE-jEl" secondAttribute="trailing" id="6At-Ny-s4i"/>
+                            <constraint firstItem="fb6-6f-oqD" firstAttribute="width" secondItem="vej-Z8-dOm" secondAttribute="width" id="6T4-XK-uNu"/>
+                            <constraint firstItem="YR8-e7-f8B" firstAttribute="top" secondItem="xUT-yB-g8Q" secondAttribute="top" id="75b-jc-goZ"/>
+                            <constraint firstAttribute="bottom" secondItem="oXB-Be-LaB" secondAttribute="bottom" id="78c-rz-zWu"/>
+                            <constraint firstItem="Qx0-KE-jEl" firstAttribute="leading" secondItem="xUT-yB-g8Q" secondAttribute="leading" id="96K-5h-fNe"/>
+                            <constraint firstItem="fb6-6f-oqD" firstAttribute="baseline" secondItem="bZ5-at-jng" secondAttribute="baseline" id="FcI-8l-Et0"/>
+                            <constraint firstItem="vej-Z8-dOm" firstAttribute="leading" secondItem="Bcr-Pl-Fz9" secondAttribute="trailing" constant="46" id="H6a-lV-9HO"/>
+                            <constraint firstItem="Bcr-Pl-Fz9" firstAttribute="baseline" secondItem="vej-Z8-dOm" secondAttribute="baseline" id="HWL-uz-9td"/>
+                            <constraint firstItem="vej-Z8-dOm" firstAttribute="top" secondItem="Qx0-KE-jEl" secondAttribute="bottom" constant="17" id="JRl-83-1RI"/>
+                            <constraint firstItem="vej-Z8-dOm" firstAttribute="width" secondItem="xUT-yB-g8Q" secondAttribute="height" multiplier="285:311" id="KWf-If-sdz"/>
+                            <constraint firstItem="bZ5-at-jng" firstAttribute="leading" secondItem="xUT-yB-g8Q" secondAttribute="leading" id="a8B-2s-qAO"/>
+                            <constraint firstItem="Qx0-KE-jEl" firstAttribute="top" secondItem="YR8-e7-f8B" secondAttribute="bottom" constant="20" id="bQT-cM-bWc"/>
+                            <constraint firstItem="bZ5-at-jng" firstAttribute="top" secondItem="Bcr-Pl-Fz9" secondAttribute="bottom" constant="26" id="hH4-Ug-Jki"/>
+                            <constraint firstAttribute="trailing" secondItem="YR8-e7-f8B" secondAttribute="trailing" id="kQs-lk-qMI"/>
+                            <constraint firstItem="vej-Z8-dOm" firstAttribute="leading" secondItem="xUT-yB-g8Q" secondAttribute="leading" constant="105" id="q8m-JB-plh"/>
+                            <constraint firstItem="vej-Z8-dOm" firstAttribute="leading" secondItem="fb6-6f-oqD" secondAttribute="leading" id="vN2-rY-7tJ"/>
+                            <constraint firstItem="YR8-e7-f8B" firstAttribute="leading" secondItem="xUT-yB-g8Q" secondAttribute="leading" id="xjG-Vn-8Kc"/>
+                            <constraint firstAttribute="trailing" secondItem="oXB-Be-LaB" secondAttribute="trailing" id="zBf-Ov-zq7"/>
+                        </constraints>
+                    </customView>
+                    <customView hidden="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ty1-sj-tT6">
+                        <rect key="frame" x="20" y="20" width="468" height="266"/>
+                        <subviews>
+                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="RfX-YR-bbB">
+                                <rect key="frame" x="-2" y="249" width="472" height="17"/>
+                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Account migration error" id="8K3-9Z-MKH">
+                                    <font key="font" metaFont="systemBold"/>
+                                    <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                                </textFieldCell>
+                            </textField>
+                            <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="G1N-th-ZtP">
+                                <rect key="frame" x="-2" y="213" width="472" height="17"/>
+                                <textFieldCell key="cell" controlSize="mini" sendsActionOnEndEditing="YES" alignment="left" placeholderString="error label" id="e7n-Ev-bK7">
+                                    <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="cxh-K7-1eh">
+                                <rect key="frame" x="415" y="-7" width="59" height="32"/>
+                                <buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="VN1-A3-RIh">
+                                    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                    <font key="font" metaFont="system"/>
+                                    <string key="keyEquivalent" base64-UTF8="YES">
+DQ
+</string>
+                                </buttonCell>
+                                <connections>
+                                    <action selector="onClickComplete:" target="-2" id="2EG-XF-KK9"/>
+                                </connections>
+                            </button>
+                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ocg-tS-V4f">
+                                <rect key="frame" x="-6" y="-7" width="158" height="32"/>
+                                <buttonCell key="cell" type="push" title="Delete this account" bezelStyle="rounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="ITE-yD-CTb">
+                                    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                    <font key="font" metaFont="system"/>
+                                </buttonCell>
+                                <connections>
+                                    <action selector="removeAccount:" target="-2" id="YxZ-Ld-ciH"/>
+                                </connections>
+                            </button>
+                        </subviews>
+                        <constraints>
+                            <constraint firstAttribute="trailing" secondItem="G1N-th-ZtP" secondAttribute="trailing" id="5R4-Fn-a0W"/>
+                            <constraint firstItem="G1N-th-ZtP" firstAttribute="top" secondItem="RfX-YR-bbB" secondAttribute="bottom" constant="19" id="7Py-Sf-rhN"/>
+                            <constraint firstAttribute="trailing" secondItem="RfX-YR-bbB" secondAttribute="trailing" id="HSv-ag-BSM"/>
+                            <constraint firstAttribute="trailing" secondItem="cxh-K7-1eh" secondAttribute="trailing" id="Y5m-0Q-V2G"/>
+                            <constraint firstAttribute="bottom" secondItem="cxh-K7-1eh" secondAttribute="bottom" id="Ygs-Cw-f5z"/>
+                            <constraint firstItem="Ocg-tS-V4f" firstAttribute="baseline" secondItem="cxh-K7-1eh" secondAttribute="baseline" id="bRj-Zl-Xeg"/>
+                            <constraint firstItem="RfX-YR-bbB" firstAttribute="leading" secondItem="ty1-sj-tT6" secondAttribute="leading" id="dkl-c9-iMz"/>
+                            <constraint firstItem="cxh-K7-1eh" firstAttribute="width" secondItem="ty1-sj-tT6" secondAttribute="height" multiplier="47:266" id="fQc-pG-Oh8"/>
+                            <constraint firstItem="Ocg-tS-V4f" firstAttribute="leading" secondItem="ty1-sj-tT6" secondAttribute="leading" id="qEX-46-QVl"/>
+                            <constraint firstItem="RfX-YR-bbB" firstAttribute="top" secondItem="ty1-sj-tT6" secondAttribute="top" id="qhq-Xf-xgq"/>
+                            <constraint firstItem="G1N-th-ZtP" firstAttribute="leading" secondItem="ty1-sj-tT6" secondAttribute="leading" id="wDt-LQ-Q7c"/>
+                        </constraints>
+                    </customView>
+                    <customView hidden="YES" translatesAutoresizingMaskIntoConstraints="NO" id="D9c-cc-43F">
+                        <rect key="frame" x="20" y="20" width="468" height="266"/>
+                        <subviews>
+                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="suF-b1-Duk">
+                                <rect key="frame" x="-2" y="249" width="472" height="17"/>
+                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Account migration completed" id="1ob-x1-u74">
+                                    <font key="font" metaFont="systemBold"/>
+                                    <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="jeD-0z-2Lj">
+                                <rect key="frame" x="415" y="-7" width="59" height="32"/>
+                                <buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="PT7-XI-WDR">
+                                    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                    <font key="font" metaFont="system"/>
+                                    <string key="keyEquivalent" base64-UTF8="YES">
+DQ
+</string>
+                                </buttonCell>
+                                <connections>
+                                    <action selector="onClickComplete:" target="-2" id="Jwe-cD-rDX"/>
+                                </connections>
+                            </button>
+                            <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="wRp-RS-wdh">
+                                <rect key="frame" x="-2" y="212" width="472" height="17"/>
+                                <textFieldCell key="cell" controlSize="mini" sendsActionOnEndEditing="YES" alignment="left" title="Congratulations, your account has been migrated with Success." placeholderString="" id="C2l-rz-Gqt">
+                                    <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>
+                        </subviews>
+                        <constraints>
+                            <constraint firstItem="wRp-RS-wdh" firstAttribute="leading" secondItem="D9c-cc-43F" secondAttribute="leading" id="22v-TA-qYj"/>
+                            <constraint firstAttribute="trailing" secondItem="jeD-0z-2Lj" secondAttribute="trailing" id="L0f-VY-bZm"/>
+                            <constraint firstAttribute="bottom" secondItem="jeD-0z-2Lj" secondAttribute="bottom" id="LOM-OT-huO"/>
+                            <constraint firstItem="wRp-RS-wdh" firstAttribute="top" secondItem="suF-b1-Duk" secondAttribute="bottom" constant="20" id="Ms2-7d-ux7"/>
+                            <constraint firstItem="suF-b1-Duk" firstAttribute="top" secondItem="D9c-cc-43F" secondAttribute="top" id="NWV-rr-iyE"/>
+                            <constraint firstAttribute="trailing" secondItem="wRp-RS-wdh" secondAttribute="trailing" id="TVY-wv-dzW"/>
+                            <constraint firstItem="suF-b1-Duk" firstAttribute="leading" secondItem="D9c-cc-43F" secondAttribute="leading" id="XVh-QA-hIY"/>
+                            <constraint firstAttribute="trailing" secondItem="suF-b1-Duk" secondAttribute="trailing" id="yLT-MQ-i57"/>
+                        </constraints>
+                    </customView>
+                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="IbM-NP-t4j">
+                        <rect key="frame" x="64" y="65" width="380" height="166"/>
+                        <subviews>
+                            <customView hidden="YES" translatesAutoresizingMaskIntoConstraints="NO" id="LsP-hk-8Om" customClass="ITProgressIndicator">
+                                <rect key="frame" x="155" y="48" width="70" height="70"/>
+                                <constraints>
+                                    <constraint firstAttribute="width" constant="70" id="Rid-Bq-sD0"/>
+                                    <constraint firstAttribute="height" constant="70" id="W0L-95-qkY"/>
+                                </constraints>
+                            </customView>
+                        </subviews>
+                        <constraints>
+                            <constraint firstItem="LsP-hk-8Om" firstAttribute="centerX" secondItem="IbM-NP-t4j" secondAttribute="centerX" id="2fW-Cs-YoP"/>
+                            <constraint firstItem="LsP-hk-8Om" firstAttribute="width" secondItem="IbM-NP-t4j" secondAttribute="height" multiplier="35:83" id="5vO-1o-a90"/>
+                            <constraint firstItem="LsP-hk-8Om" firstAttribute="centerY" secondItem="IbM-NP-t4j" secondAttribute="centerY" id="MKG-ve-nSR"/>
+                        </constraints>
+                    </customView>
+                </subviews>
+                <constraints>
+                    <constraint firstItem="xUT-yB-g8Q" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" constant="20" id="1qc-WS-pWN"/>
+                    <constraint firstAttribute="trailing" secondItem="ty1-sj-tT6" secondAttribute="trailing" constant="20" id="44x-w8-5VH"/>
+                    <constraint firstAttribute="trailing" secondItem="D9c-cc-43F" secondAttribute="trailing" constant="20" id="7ik-2Z-GeU"/>
+                    <constraint firstItem="xUT-yB-g8Q" firstAttribute="top" secondItem="EiT-Mj-1SZ" secondAttribute="top" constant="10" id="S2Y-12-IY1"/>
+                    <constraint firstItem="D9c-cc-43F" firstAttribute="top" secondItem="EiT-Mj-1SZ" secondAttribute="top" constant="10" id="VLa-s1-YI3"/>
+                    <constraint firstItem="ty1-sj-tT6" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" constant="20" id="bD3-zJ-ba1"/>
+                    <constraint firstItem="D9c-cc-43F" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" constant="20" id="f0A-2H-xAe"/>
+                    <constraint firstAttribute="bottom" secondItem="D9c-cc-43F" secondAttribute="bottom" constant="20" id="glP-hH-xFO"/>
+                    <constraint firstAttribute="bottom" secondItem="xUT-yB-g8Q" secondAttribute="bottom" constant="20" id="lo1-Yf-zAT"/>
+                    <constraint firstItem="IbM-NP-t4j" firstAttribute="centerY" secondItem="EiT-Mj-1SZ" secondAttribute="centerY" id="lyo-09-ohw"/>
+                    <constraint firstAttribute="trailing" secondItem="xUT-yB-g8Q" secondAttribute="trailing" constant="20" id="mAW-UW-MB6"/>
+                    <constraint firstItem="ty1-sj-tT6" firstAttribute="top" secondItem="EiT-Mj-1SZ" secondAttribute="top" constant="10" id="p6k-5L-CM6"/>
+                    <constraint firstItem="IbM-NP-t4j" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" constant="64" id="qwU-CI-kYh"/>
+                    <constraint firstItem="IbM-NP-t4j" firstAttribute="centerX" secondItem="D9c-cc-43F" secondAttribute="centerX" id="xfx-og-DXk"/>
+                    <constraint firstAttribute="bottom" secondItem="ty1-sj-tT6" secondAttribute="bottom" constant="20" id="xny-Om-PuU"/>
+                </constraints>
+            </view>
+            <connections>
+                <outlet property="delegate" destination="-2" id="3wn-SC-48D"/>
+            </connections>
+            <point key="canvasLocation" x="-1875" y="-234"/>
+        </window>
+        <userDefaultsController representsSharedInstance="YES" id="2A5-Q9-edp"/>
+    </objects>
+</document>
diff --git a/ui/Base.lproj/PathPasswordWindow.xib b/ui/Base.lproj/PathPasswordWindow.xib
index 4fd608a..431d8a7 100644
--- a/ui/Base.lproj/PathPasswordWindow.xib
+++ b/ui/Base.lproj/PathPasswordWindow.xib
@@ -24,7 +24,7 @@
             <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
             <rect key="contentRect" x="196" y="240" width="351" height="131"/>
-            <rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="1440" height="900"/>
             <view key="contentView" id="EiT-Mj-1SZ">
                 <rect key="frame" x="0.0" y="0.0" width="351" height="131"/>
                 <autoresizingMask key="autoresizingMask"/>