Added change-password and format functionality.
authorJimmy Christensen <dusted@dusted.dk>
Wed, 1 Apr 2015 16:37:30 +0000 (19:37 +0300)
committerJimmy Christensen <dusted@dusted.dk>
Wed, 1 Apr 2015 16:37:30 +0000 (19:37 +0300)
src/fkgui/ChangePassPrompt.java [new file with mode: 0644]
src/fkgui/FkManager.java
src/fkgui/MainWin.java
src/fkgui/Messages.java
src/fkgui/messages.properties

diff --git a/src/fkgui/ChangePassPrompt.java b/src/fkgui/ChangePassPrompt.java
new file mode 100644 (file)
index 0000000..c1e12ef
--- /dev/null
@@ -0,0 +1,432 @@
+package fkgui;
+
+import org.eclipse.swt.widgets.Dialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.ProgressBar;
+
+public class ChangePassPrompt extends Dialog implements FkActionEventListener {
+
+       protected Object result;
+       protected Shell shell;
+       private Text txtCurrentPass;
+       private Label label;
+       private Label lblNewLabel_1;
+       private Text txtNewPassA;
+       private Text txtNewPassB;
+       private Label lblRepeat;
+       private Label label_1;
+       private Button btnAbort;
+       private Button btnGo;
+       private boolean format;
+       private ChangePassPrompt mySelf;
+       public String newLayout;
+       public String newBanner;
+       
+       private Composite content;
+       
+       //
+       Label lblProgressMsg;
+       Button btnClose;
+       ProgressBar progressBar;
+       
+       //
+       Animation animation;
+       private Label lblWaitText;
+       
+       /**
+        * Create the dialog.
+        * @param parent
+        * @param style
+        */
+       public ChangePassPrompt(Shell parent, int style) {
+               super(parent, style);
+               mySelf = this;
+       }
+
+       /**
+        * Open the dialog.
+        * @return the result
+        */
+       public Object open(boolean f) {
+               this.format=f;
+               createContents();
+               shell.open();
+               shell.layout();
+               Display display = getParent().getDisplay();
+               while (!shell.isDisposed()) {
+                       if (!display.readAndDispatch()) {
+                               display.sleep();
+                       }
+               }
+               return result;
+       }
+
+       /**
+        * Create contents of the dialog.
+        */
+       private void createContents() {
+               shell = new Shell(getParent(), getStyle());
+               shell.setSize(450, 168);
+               shell.setText(getText());
+               shell.setLayout(new FormLayout());
+               
+               createPswEntry();
+               //createProgress();
+               //createWaiting();
+
+       
+       }
+       
+       
+       
+       private void createPswEntry()
+       {
+               content = new Composite(shell, SWT.NONE);
+               content.setLayout(new FormLayout());
+               FormData fd_content = new FormData();
+               fd_content.top = new FormAttachment(0);
+               fd_content.left = new FormAttachment(0);
+               fd_content.right = new FormAttachment(100);
+               fd_content.bottom = new FormAttachment(100);
+               content.setLayoutData(fd_content);
+
+               Label lblNewLabel = new Label(content, SWT.NONE);
+               lblNewLabel.setAlignment(SWT.RIGHT);
+               FormData fd_lblNewLabel = new FormData();
+               fd_lblNewLabel.top = new FormAttachment(0, 10);
+               fd_lblNewLabel.left = new FormAttachment(0, 10);
+               lblNewLabel.setLayoutData(fd_lblNewLabel);
+               lblNewLabel.setText("Current Password");
+
+               txtCurrentPass = new Text(content, SWT.BORDER | SWT.PASSWORD);
+               fd_lblNewLabel.right = new FormAttachment(txtCurrentPass, -6);
+               FormData fd_txtCurrentPass = new FormData();
+               fd_txtCurrentPass.left = new FormAttachment(100, -298);
+               fd_txtCurrentPass.top = new FormAttachment(0, 10);
+               fd_txtCurrentPass.right = new FormAttachment(100, -10);
+               txtCurrentPass.setLayoutData(fd_txtCurrentPass);
+
+               label = new Label(content, SWT.SEPARATOR | SWT.HORIZONTAL);
+               FormData fd_label = new FormData();
+               fd_label.top = new FormAttachment(txtCurrentPass, 6);
+               fd_label.bottom = new FormAttachment(txtCurrentPass, 7, SWT.BOTTOM);
+               fd_label.right = new FormAttachment(txtCurrentPass, 0, SWT.RIGHT);
+               fd_label.left = new FormAttachment(0, 10);
+               label.setLayoutData(fd_label);
+
+               lblNewLabel_1 = new Label(content, SWT.NONE);
+               lblNewLabel_1.setAlignment(SWT.RIGHT);
+               FormData fd_lblNewLabel_1 = new FormData();
+               fd_lblNewLabel_1.left = new FormAttachment(lblNewLabel, 0, SWT.LEFT);
+               fd_lblNewLabel_1.top = new FormAttachment(label, 6);
+               fd_lblNewLabel_1.right = new FormAttachment(lblNewLabel, 0, SWT.RIGHT);
+               lblNewLabel_1.setLayoutData(fd_lblNewLabel_1);
+               lblNewLabel_1.setText("New Password");
+
+               txtNewPassA = new Text(content, SWT.BORDER | SWT.PASSWORD);
+               FormData fd_txtNewPassA = new FormData();
+               fd_txtNewPassA.right = new FormAttachment(100, -10);
+               fd_txtNewPassA.top = new FormAttachment(label, 6);
+               fd_txtNewPassA.left = new FormAttachment(txtCurrentPass, 0, SWT.LEFT);
+               txtNewPassA.setLayoutData(fd_txtNewPassA);
+
+               txtNewPassB = new Text(content, SWT.BORDER | SWT.PASSWORD);
+               FormData fd_txtNewPassB = new FormData();
+               fd_txtNewPassB.left = new FormAttachment(txtCurrentPass, 0, SWT.LEFT);
+               fd_txtNewPassB.top = new FormAttachment(txtNewPassA, 6);
+               fd_txtNewPassB.right = new FormAttachment(txtCurrentPass, 0, SWT.RIGHT);
+               txtNewPassB.setLayoutData(fd_txtNewPassB);
+
+               lblRepeat = new Label(content, SWT.NONE);
+               lblRepeat.setText("Repeat");
+               lblRepeat.setAlignment(SWT.RIGHT);
+               FormData fd_lblRepeat = new FormData();
+               fd_lblRepeat.left = new FormAttachment(0, 10);
+               fd_lblRepeat.top = new FormAttachment(txtNewPassB, 0, SWT.TOP);
+               fd_lblRepeat.right = new FormAttachment(lblNewLabel, 0, SWT.RIGHT);
+               lblRepeat.setLayoutData(fd_lblRepeat);
+
+               label_1 = new Label(content, SWT.SEPARATOR | SWT.HORIZONTAL);
+               FormData fd_label_1 = new FormData();
+               fd_label_1.top = new FormAttachment(txtNewPassB, 6);
+               fd_label_1.bottom = new FormAttachment(txtNewPassB, 7, SWT.BOTTOM);
+               fd_label_1.left = new FormAttachment(lblNewLabel, 0, SWT.LEFT);
+               fd_label_1.right = new FormAttachment(100, -10);
+               label_1.setLayoutData(fd_label_1);
+
+               btnAbort = new Button(content, SWT.NONE);
+               FormData fd_btnAbort = new FormData();
+               fd_btnAbort.top = new FormAttachment(label_1, 5);
+               fd_btnAbort.left = new FormAttachment(lblNewLabel, 0, SWT.LEFT);
+               btnAbort.setLayoutData(fd_btnAbort);
+               btnAbort.setText("Abort");
+               btnAbort.addSelectionListener( new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               shell.close();
+                       }
+               });
+
+               btnGo = new Button(content, SWT.NONE);
+               FormData fd_btnGo = new FormData();
+               fd_btnGo.left = new FormAttachment(txtCurrentPass, -89);
+               fd_btnGo.top = new FormAttachment(btnAbort, -22);
+               fd_btnGo.bottom = new FormAttachment(btnAbort, 0, SWT.BOTTOM);
+               fd_btnGo.right = new FormAttachment(txtCurrentPass, 0, SWT.RIGHT);
+               btnGo.setLayoutData(fd_btnGo);
+               btnGo.addSelectionListener( new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               MessageBox m;
+
+                               shell.setEnabled(false);
+
+                               if( txtNewPassA.getText().compareTo(txtNewPassB.getText()) == 0 )
+                               {
+                                       if( txtNewPassA.getText().length() < 10 )
+                                       {
+                                               m = new MessageBox(shell, SWT.ICON_WARNING|SWT.YES|SWT.NO);
+                                               m.setText("Short password");
+                                               m.setMessage("Secure passwords need to be long and complex. Your password can be up to 32 characters long, do you want to continue with the short password?");
+                                               if( m.open() == SWT.YES )
+                                               {
+                                                       if( format )
+                                                       {
+                                                               FkManager.getInstance().format( txtCurrentPass.getText(), txtNewPassA.getText(), newLayout, newBanner, mySelf );
+                                                       } else {
+                                                               FkManager.getInstance().changePass( txtCurrentPass.getText(), txtNewPassA.getText(), mySelf );
+                                                       }
+                                               } else {
+                                                       shell.setEnabled(true);
+                                               }
+
+                                       }
+                               } else {
+                                       m = new MessageBox(shell, SWT.ICON_ERROR);
+                                       m.setText("Passwords do not match");
+                                       m.setMessage("The new passwords you entered do not match, try again.");
+                                       m.open();
+                                       shell.setEnabled(true);
+                               }
+                       }
+
+               });
+               
+
+               if( format )
+               {
+                       btnGo.setText("Format");
+                       setText("Format your FinalKey");
+               } else {
+                       btnGo.setText("Re-Encrypt");
+                       setText("Change password");
+               }
+               
+       }
+
+
+       private void createProgress()
+       {
+               content = new Composite(shell, SWT.NONE);
+               content.setLayout(new FormLayout());
+               FormData fd_content = new FormData();
+               fd_content.bottom = new FormAttachment(0, 143);
+               fd_content.right = new FormAttachment(0, 448);
+               fd_content.top = new FormAttachment(0);
+               fd_content.left = new FormAttachment(0);
+               content.setLayoutData(fd_content);
+
+               lblProgressMsg = new Label(content, SWT.NONE);
+               FormData fd_lblProgressMsg = new FormData();
+               fd_lblProgressMsg.top = new FormAttachment(0, 10);
+               fd_lblProgressMsg.left = new FormAttachment(0, 10);
+               fd_lblProgressMsg.bottom = new FormAttachment(0, 36);
+               fd_lblProgressMsg.right = new FormAttachment(100, -10);
+               lblProgressMsg.setLayoutData(fd_lblProgressMsg);
+               
+               if(format )
+               {
+                       lblProgressMsg.setText("Formatting...");
+               } else {
+                       lblProgressMsg.setText("Re-encrypting... Do not unplug The FinalKey!");
+               }
+
+               progressBar = new ProgressBar(content, SWT.NONE);
+               progressBar.setMaximum(255);
+               FormData fd_progressBar = new FormData();
+               fd_progressBar.top = new FormAttachment(lblProgressMsg, 6);
+               fd_progressBar.left = new FormAttachment(0, 10);
+               fd_progressBar.right = new FormAttachment(100, -10);
+               progressBar.setLayoutData(fd_progressBar);
+
+               btnClose = new Button(content, SWT.NONE);
+               FormData fd_btnClose = new FormData();
+               fd_btnClose.bottom = new FormAttachment(100, -10);
+               fd_btnClose.right = new FormAttachment(lblProgressMsg, 0, SWT.RIGHT);
+               btnClose.setLayoutData(fd_btnClose);
+               btnClose.setText("Done");
+               btnClose.setVisible(false);
+               
+               btnClose.addSelectionListener( new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               if(format)
+                               {
+                                       FkManager.getInstance().disconnect();
+                               }
+                               shell.close();
+                       }
+                       
+               });
+               
+               
+       }
+       
+       private void createWaiting()
+       {
+               content = new Composite(shell, SWT.NONE);
+               content.setLayout(new FormLayout());
+               FormData fd_content = new FormData();
+               fd_content.top = new FormAttachment(0);
+               fd_content.left = new FormAttachment(0);
+               fd_content.bottom = new FormAttachment(100);
+               fd_content.right = new FormAttachment(100);
+               content.setLayoutData(fd_content);
+               
+               animation = new Animation(content, SWT.NONE, 4);
+               FormData fd_animation = new FormData();
+               fd_animation.top = new FormAttachment(0, 10);
+               fd_animation.left = new FormAttachment(0, 10);
+               animation.setLayoutData(fd_animation);
+               
+               lblWaitText = new Label(content, SWT.NONE);
+               FormData fd_lblWaitText = new FormData();
+               fd_lblWaitText.bottom = new FormAttachment(0, 133);
+               fd_lblWaitText.right = new FormAttachment(animation, 396, SWT.RIGHT);
+               fd_lblWaitText.top = new FormAttachment(0, 10);
+               fd_lblWaitText.left = new FormAttachment(animation, 6);
+               lblWaitText.setLayoutData(fd_lblWaitText);
+               animation.setVisible(true);
+               animation.setPlaying(true);
+       }
+
+       private void createWorking()
+       {
+               content = new Composite(shell, SWT.NONE);
+               content.setLayout(new FormLayout());
+               FormData fd_content = new FormData();
+               fd_content.top = new FormAttachment(0);
+               fd_content.left = new FormAttachment(0);
+               fd_content.bottom = new FormAttachment(100);
+               fd_content.right = new FormAttachment(100);
+               content.setLayoutData(fd_content);
+
+               lblWaitText = new Label(content, SWT.NONE);
+               FormData fd_lblWaitText = new FormData();
+               fd_lblWaitText.bottom = new FormAttachment(0, 133);
+               fd_lblWaitText.right = new FormAttachment(animation, 396, SWT.RIGHT);
+               fd_lblWaitText.top = new FormAttachment(0, 10);
+               fd_lblWaitText.left = new FormAttachment(animation, 6);
+               lblWaitText.setLayoutData(fd_lblWaitText);
+               lblWaitText.setText("Working...");
+
+       }
+       
+       @Override
+       public void fkActionEvent(FkActionEvent event) {
+               
+               MessageBox d;
+               System.out.println("Event: "+event);
+               
+               switch( event.type )
+               {
+               case ACTION_ABORTED:
+                       d = new MessageBox(shell, SWT.ICON_WARNING);
+                       d.setText("Aborted");
+                       if(format)
+                       {
+                               d.setMessage("Formatting was aborted.\nMaybe you did not press the FinalKey button in time, or you held it down.");
+                       } else {
+                               d.setMessage("Re-encryption was aborted.\nMaybe you did not press the FinalKey button in time, or you held it down.");
+                       }
+                       d.open();
+                       shell.close();
+                       break;
+               case STATE_ERROR:
+               case ACTION_ERROR:
+                       d = new MessageBox(shell, SWT.ICON_ERROR);
+                       d.setText("Error");
+                       d.setMessage(event.data);
+                       d.open();
+                       shell.close();
+                       break;
+               case ACTION_OKAY:
+                       btnClose.setVisible(true);
+                       shell.setEnabled(true);
+                       
+                       if( format )
+                       {
+                               lblProgressMsg.setText("Format complete.");
+                       } else {
+                               lblProgressMsg.setText("Re-encryption complete.");
+                       }
+
+                       break;
+               case ACTION_WAITING:
+                       content.dispose();
+                       createWaiting();
+
+
+                       if( event.action == 'p' )
+                       {
+                               lblWaitText.setText("Press FinalKey button to re-encrypt.\nPress and hold to abort.");
+                       } else if( event.action == 'f' )
+                       {
+                               if( event.data.compareTo("stage1")==0 )
+                               {
+                                       lblWaitText.setText("Press button to format.\nPress and hold to abort.");
+                               } else {
+                                       lblWaitText.setText("Press button again.");
+                               }
+                       }
+                       shell.layout();
+
+                       break;
+               case ACTION_WORKING:
+                       content.dispose();
+                       if( event.data.compareTo( "next" )==0 )
+                       {
+                               createProgress();
+                       } else {
+                               createWorking();
+                       }
+                       shell.layout();
+                       break;
+               case FILE_ERROR:
+                       break;
+               case PROGRESS_UPDATE:
+                       try {
+                               progressBar.setSelection( Integer.parseInt(event.data) );
+                       } catch(Exception e)
+                       {
+                               
+                       }
+                       break;
+               case UNEXPECTED_ACTION_RESULT_ERROR:
+                       break;
+               default:
+                       break;
+               
+               }
+               
+       }
+}
index 8e232e5..3c52867 100644 (file)
@@ -6,13 +6,20 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.charset.spi.CharsetProvider;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Vector;
 
 import jssc.SerialPort;
+import jssc.SerialPortException;
 
 import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Text;
+
+import sun.awt.CharsetString;
+import sun.util.locale.provider.AvailableLanguageTags;
 
 import com.sun.corba.se.impl.ior.ByteBuffer;
 
@@ -1339,6 +1346,318 @@ public class FkManager implements ActionListener {
 
        public void disconnect() {
                com.disconnect();
+               supportedLayouts.clear();
+               list.clear();
+       }
+       
+       private class ChangePassTask implements Runnable
+       {
+
+               private FkActionEventListener delegate;
+               private String curPass;
+               private String newPass;
+
+               public ChangePassTask(String _curPass, String _newPass, FkActionEventListener d )
+               {
+                       curPass = _curPass;
+                       newPass = _newPass;
+                       delegate=d;
+               }
+
+
+               @Override
+               public void run() {
+               
+                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_WORKING, "1",null,'p') );
+                       
+                       String data="";
+                       int state=0;
+                       //First check that we get a prompt
+                       if( !checkState() )
+                       {
+                               Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.STATE_ERROR, "EXCEPTION",null,'p') );
+                               return;
+                       }
+
+                       //Drain any previous input.
+                       try {
+                               while( com.serialPort.getInputBufferBytesCount() > 0 )
+                               {
+                                       com.serialPort.readBytes();
+                               }
+                               com.serialPort.writeByte((byte)'x');
+                               com.serialPort.writeByte((byte)'p');
+                               
+                               long timeStamp=System.currentTimeMillis();
+                                                               
+                               
+                               while(System.currentTimeMillis() - timeStamp < 15000L)
+                               {
+                                       
+                                       while( com.serialPort.getInputBufferBytesCount() > 0 )
+                                       {
+                                               data += com.serialPort.readString();
+                                               if( state==0 && data.contains("Are you sure [y/n] ?") )
+                                               {
+                                                       data="";
+                                                       com.serialPort.writeByte((byte)'y');
+                                                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_WAITING, "WAITING",null,'p') );
+                                                       state++;
+                                               }
+
+                                               if( state==1 && data.contains("Current psw:"))
+                                               {
+                                                       timeStamp=System.currentTimeMillis();
+                                                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_WORKING, "WORKING",null,'p') );
+                                                       data="";
+                                                       com.serialPort.writeBytes( curPass.getBytes() );
+                                                       com.serialPort.writeByte( (byte) ENTER_KEY );
+                                                       state++;
+                                               }
+                                               
+                                               if( state==2 && data.contains("New psw:") )
+                                               {
+                                                       data="";
+                                                       com.serialPort.writeBytes( newPass.getBytes() );
+                                                       com.serialPort.writeByte( (byte) ENTER_KEY );
+                                                       state++;
+                                               }
+                                               if( state==3 && data.contains("Repeat:") )
+                                               {
+                                                       data="";
+                                                       com.serialPort.writeBytes( newPass.getBytes() );
+                                                       com.serialPort.writeByte( (byte) ENTER_KEY );
+                                                       state++;
+
+                                               }
+                                               
+                                               if( state==4 && data.contains("Changing password.")&& data.contains("Encrypting:") )
+                                               {
+                                                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_WORKING, "next",null,'p') );
+                                                       data="";
+                                                       state++;
+                                               }
+                                               
+                                               if( state==5 && data.contains("/255") )
+                                               {
+                                                       timeStamp=System.currentTimeMillis();
+                                                       String p=data.substring( 1, data.indexOf('/') );
+                                                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.PROGRESS_UPDATE, p ,null,'p') );
+                                                       data="";
+                                               }
+                                               
+                                               if( state==5 && data.contains("[done]") )
+                                               {
+                                                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_OKAY, "",null,'p') );
+                                                       return;
+                                               }
+       
+                                               if( state== 1 && data.contains("[abort]") )
+                                               {
+                                                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_ABORTED, "",null,'p') );
+                                                       return;
+                                               }
+
+                                               if( state == 2 && data.contains("[abort]") )
+                                               {
+                                                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_ERROR, "Current password was not accepted.",null,'p') );
+                                                       return;
+                                               }
+                                       }
+
+
+                               }
+
+                               Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_ERROR, "Timeout ",null,'p') );
+
+                       } catch (SerialPortException e) {
+                               Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.STATE_ERROR, "exception:"+e.getLocalizedMessage(),null,'p') );
+                               return;
+                       }
+
+               }
+       }
+
+       public void changePass(String currentPass, String newPass, FkActionEventListener delegate) {
+               ChangePassTask ct = new ChangePassTask(currentPass, newPass, delegate);
+               new Thread(ct).start();
+       }
+       
+
+       private class FormatTask implements Runnable
+       {
+
+               private FkActionEventListener delegate;
+               private String curPass;
+               private String newPass;
+               private String newLayout;
+               private String newBanner;
+
+               public FormatTask(String _curPass, String _newPass, String nl, String nb, FkActionEventListener d )
+               {
+                       newBanner=nb;
+                       newLayout=nl;
+                       curPass = _curPass;
+                       newPass = _newPass;
+                       delegate=d;
+               }
+
+
+               @Override
+               public void run() {
+               
+                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_WORKING, "1",null,'f') );
+                       
+                       String data="";
+                       int state=0;
+                       //First check that we get a prompt
+                       if( !checkState() )
+                       {
+                               Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.STATE_ERROR, "EXCEPTION",null,'f') );
+                               return;
+                       }
+
+                       //Drain any previous input.
+                       try {
+                               while( com.serialPort.getInputBufferBytesCount() > 0 )
+                               {
+                                       com.serialPort.readBytes();
+                               }
+                               com.serialPort.writeByte((byte)'x');
+                               com.serialPort.writeByte((byte)'f');
+
+                               long timeStamp=System.currentTimeMillis();
+
+                               while(System.currentTimeMillis() - timeStamp < 15000L)
+                               {
+
+                                       while( com.serialPort.getInputBufferBytesCount() > 0 )
+                                       {
+                                               data += com.serialPort.readString();
+
+                                               if( state==0 && data.contains("Are you sure [y/n] ?") )
+                                               {
+                                                       data="";
+                                                       com.serialPort.writeByte((byte)'y');
+                                                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_WAITING, "WAITING",null,'f') );
+                                                       state++;
+                                               }
+
+                                               if( state==1 && data.contains("Current psw:"))
+                                               {
+                                                       timeStamp=System.currentTimeMillis();
+                                                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_WORKING, "WORKING",null,'f') );
+                                                       data="";
+                                                       com.serialPort.writeBytes( curPass.getBytes() );
+                                                       com.serialPort.writeByte( (byte) ENTER_KEY );
+                                                       state++;
+                                               }
+
+                                               if( state==2 && data.contains("Psw:") )
+                                               {
+                                                       data="";
+                                                       com.serialPort.writeBytes( newPass.getBytes() );
+                                                       com.serialPort.writeByte( (byte) ENTER_KEY );
+                                                       state++;
+                                               }
+
+                                               if( state==3 && data.contains("Repeat:") )
+                                               {
+                                                       data="";
+                                                       com.serialPort.writeBytes( newPass.getBytes() );
+                                                       com.serialPort.writeByte( (byte) ENTER_KEY );
+                                                       state++;
+                                               }
+
+                                               if( state==4 && data.contains("Name, (0-31):\r\n"))
+                                               {
+                                                       com.serialPort.writeBytes( newBanner.getBytes() );
+                                                       com.serialPort.writeByte( (byte) ENTER_KEY );
+                                                       //
+                                                       data="";
+                                                       state++;
+                                               }
+
+                                               if( state==5 && data.contains("Select keyboard layout:\r\n") && data.contains("% ") )
+                                               {
+                                                       timeStamp=System.currentTimeMillis()+15000;
+                                                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_WAITING, "WAITING",null,'f') );
+
+                                                       
+                                                       
+                                                       com.serialPort.writeBytes( newLayout.getBytes() );
+
+                                                       data="";
+                                                       state++;
+                                               }
+
+                                               if( state==6 && data.contains("Correct [y/n] ?") )
+                                               {
+                                                       com.serialPort.writeByte( (byte) 'y' );
+                                                       state++;
+                                               } else if( state==6 && data.contains("[skip test]") )
+                                               {
+                                                       state++;
+                                               }
+                                               
+                                               if( state==7 && data.contains("Formatting:") )
+                                               {
+                                                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_WORKING, "next",null,'f') );
+                                                       data="";
+                                                       state++;
+                                               }
+                                               
+                                               if( state==8 && data.contains("/255"))
+                                               {
+                                                       timeStamp=System.currentTimeMillis();
+                                                       String p=data.substring( 1, data.indexOf('/') );
+                                                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.PROGRESS_UPDATE, p ,null,'f') );
+                                                       data="";
+                                               }
+                                               
+                                               if( state==8 && data.contains("[Done]") )
+                                               {
+                                                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_OKAY, "",null,'p') );
+                                                       return;
+                                               }
+                                               
+                                               
+
+                                               
+                                               if( state== 1 && data.contains("[abort]") )
+                                               {
+                                                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_ABORTED, "",null,'f') );
+                                                       return;
+                                               }
+
+                                               if( state == 2 && data.contains("[lock]") )
+                                               {
+                                                       Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_ERROR, "Current password was not accepted.",null,'f') );
+                                                       return;
+                                               }
+                                       }
+
+
+                               }
+
+                               Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.ACTION_ERROR, "Timeout ",null,'f') );
+
+                       } catch (SerialPortException e) {
+                               Display.getDefault().asyncExec( new FkActionEventMsg(delegate, FkActionEventListener.FkActionEventType.STATE_ERROR, "exception:"+e.getLocalizedMessage(),null,'f') );
+                               return;
+                       }
+
+               }
+       }
+
+       public void format(String currentPass, String newPass, String newLayout, String newBanner, FkActionEventListener delegate) {
+               FormatTask ft = new FormatTask(currentPass, newPass, newLayout, newBanner, delegate);
+               new Thread(ft).start();
+       }
+
+       public String getCurrentLayoutIndex(String l) {
+               
+               return ""+(supportedLayouts.indexOf( l )+1);
        }
 
 }
index 7691313..72ce011 100644 (file)
@@ -132,19 +132,13 @@ public class MainWin implements ConsoleMsg, UpdateCheckResultListener {
        private Text txtBanner; 
        private Combo cmbLayout;
        private Group grpBackupAndRestore;
-       private Group group_1;
-       private Label label;
-       private Text text_1;
-       private Text text_2;
-       private Text text_3;
-       private Label label_1;
-       private Label label_2;
-       private Label label_3;
-       private Button button;
+       private Group grpChangePassword;
+       private Label lblAlwaysUseA;
+       private Button btnReencrypt;
        private Group grpFormat;
        private Label lblNewLabel;
        private Button btnNewButton;
-       private Button btnNewButton_1;
+       private Button btnFormat;
        
        private Button btnFkSettingsSave;
        private Label lblMakeSureYou;
@@ -804,16 +798,16 @@ public class MainWin implements ConsoleMsg, UpdateCheckResultListener {
                Label lblBannerName = new Label(group, SWT.NONE);
                lblBannerName.setAlignment(SWT.RIGHT);
                FormData fd_lblBannerName = new FormData();
-               fd_lblBannerName.left = new FormAttachment(0, 10);
-               fd_lblBannerName.top = new FormAttachment(0, 10);
                lblBannerName.setLayoutData(fd_lblBannerName);
                lblBannerName.setText(Messages.MainWin_lblBannerName_text);
 
                txtBanner = new Text(group, SWT.BORDER);
                fd_lblBannerName.right = new FormAttachment(txtBanner, -6);
+               fd_lblBannerName.left = new FormAttachment(txtBanner, -139, SWT.LEFT);
+               fd_lblBannerName.bottom = new FormAttachment(txtBanner, 0, SWT.CENTER);
                FormData fd_txtBanner = new FormData();
-               fd_txtBanner.right = new FormAttachment(0, 455);
-               fd_txtBanner.top = new FormAttachment(0, 10);
+               fd_txtBanner.right = new FormAttachment(0, 395);
+               //fd_txtBanner.right = new FormAttachment(0, 455);
                fd_txtBanner.left = new FormAttachment(0, 149);
                txtBanner.setLayoutData(fd_txtBanner);
                txtBanner.setToolTipText(Messages.MainWin_text_1_toolTipText);
@@ -848,17 +842,17 @@ public class MainWin implements ConsoleMsg, UpdateCheckResultListener {
                Label lblKeyboardLayout = new Label(group, SWT.NONE);
                lblKeyboardLayout.setAlignment(SWT.RIGHT);
                FormData fd_lblKeyboardLayout = new FormData();
+               fd_lblKeyboardLayout.bottom = new FormAttachment(100, -27);
+               fd_lblKeyboardLayout.right = new FormAttachment(lblBannerName, 0, SWT.RIGHT);
                fd_lblKeyboardLayout.left = new FormAttachment(0, 10);
-               fd_lblKeyboardLayout.bottom = new FormAttachment(100, -13);
                lblKeyboardLayout.setLayoutData(fd_lblKeyboardLayout);
                lblKeyboardLayout.setText(Messages.MainWin_lblKeyboardLayout_text);
 
                cmbLayout = new Combo(group, SWT.READ_ONLY);
-               fd_lblKeyboardLayout.right = new FormAttachment(cmbLayout, -6);
                FormData fd_cmbLayout = new FormData();
-               fd_cmbLayout.bottom = new FormAttachment(100, -11);
                fd_cmbLayout.top = new FormAttachment(txtBanner, 6);
-               fd_cmbLayout.right = new FormAttachment(0, 301);
+               fd_cmbLayout.bottom = new FormAttachment(100, -23);
+               fd_cmbLayout.right = new FormAttachment(0, 395);
                fd_cmbLayout.left = new FormAttachment(0, 149);
                cmbLayout.setLayoutData(fd_cmbLayout);
                cmbLayout.setItems( FkManager.getInstance().getAvailableLayouts() );
@@ -881,7 +875,7 @@ public class MainWin implements ConsoleMsg, UpdateCheckResultListener {
                FormData fd_grpBackupAndRestore = new FormData();
                fd_grpBackupAndRestore.top = new FormAttachment(group, 6);
                fd_grpBackupAndRestore.left = new FormAttachment(0, 10);
-               fd_grpBackupAndRestore.bottom = new FormAttachment(0, 243);
+               fd_grpBackupAndRestore.bottom = new FormAttachment(0, 224);
                fd_grpBackupAndRestore.right = new FormAttachment(100, -10);
 
                btnFkSettingsSave = new Button(group, SWT.NONE);
@@ -908,27 +902,27 @@ public class MainWin implements ConsoleMsg, UpdateCheckResultListener {
                        }
                });
                FormData fd_btnSave = new FormData();
-               fd_btnSave.right = new FormAttachment(txtBanner, 68, SWT.RIGHT);
-               fd_btnSave.top = new FormAttachment(lblBannerName, 0, SWT.TOP);
-               fd_btnSave.left = new FormAttachment(txtBanner, 6);
+               fd_btnSave.left = new FormAttachment(cmbLayout, 218);
+               fd_btnSave.right = new FormAttachment(100, -10);
+               fd_btnSave.bottom = new FormAttachment(100, -3);
                btnFkSettingsSave.setLayoutData(fd_btnSave);
                btnFkSettingsSave.setText(Messages.MainWin_btnSave_text);
                grpBackupAndRestore.setLayoutData(fd_grpBackupAndRestore);
                btnFkSettingsSave.setEnabled(false);
 
-               group_1 = new Group(composite, SWT.NONE);
-               group_1.setText("Security");
-               group_1.setLayout(new FormLayout());
-               FormData fd_group_1 = new FormData();
-               fd_group_1.bottom = new FormAttachment(grpBackupAndRestore, 197, SWT.BOTTOM);
-               fd_group_1.top = new FormAttachment(grpBackupAndRestore, 6);
+               grpChangePassword = new Group(composite, SWT.NONE);
+               grpChangePassword.setText(Messages.MainWin_grpChangePassword_text);
+               grpChangePassword.setLayout(new FormLayout());
+               FormData fd_grpChangePassword = new FormData();
+               fd_grpChangePassword.top = new FormAttachment(grpBackupAndRestore, 6);
+               fd_grpChangePassword.right = new FormAttachment(group, 0, SWT.RIGHT);
 
                Button btnBackup = new Button(grpBackupAndRestore, SWT.CENTER);
                btnBackup.setImage(SWTResourceManager.getImage(MainWin.class, "/fkgui/gfx/backup.png"));
                FormData fd_btnBackup = new FormData();
-               fd_btnBackup.left = new FormAttachment(0, 10);
                fd_btnBackup.top = new FormAttachment(0, 10);
-               fd_btnBackup.bottom = new FormAttachment(100, -28);
+               fd_btnBackup.bottom = new FormAttachment(100, -10);
+               fd_btnBackup.left = new FormAttachment(0, 10);
                btnBackup.setLayoutData(fd_btnBackup);
                btnBackup.setText(Messages.MainWin_btnBackupYourFinalkey_text);
                btnBackup.addSelectionListener(new SelectionAdapter() {
@@ -944,9 +938,9 @@ public class MainWin implements ConsoleMsg, UpdateCheckResultListener {
                btnNewButton = new Button(grpBackupAndRestore, SWT.NONE);
                btnNewButton.setImage(SWTResourceManager.getImage(MainWin.class, "/fkgui/gfx/restore.png"));
                FormData fd_btnNewButton = new FormData();
-               fd_btnNewButton.top = new FormAttachment(0, 10);
+               fd_btnNewButton.bottom = new FormAttachment(btnBackup, 0, SWT.BOTTOM);
                fd_btnNewButton.right = new FormAttachment(100, -10);
-               fd_btnNewButton.bottom = new FormAttachment(100, -28);
+               fd_btnNewButton.top = new FormAttachment(0, 10);
                btnNewButton.setLayoutData(fd_btnNewButton);
                btnNewButton.setText(Messages.MainWin_btnNewButton_text);
                btnNewButton.addSelectionListener(new SelectionAdapter() {
@@ -961,98 +955,98 @@ public class MainWin implements ConsoleMsg, UpdateCheckResultListener {
                
                lblMakeSureYou = new Label(grpBackupAndRestore, SWT.NONE);
                fd_btnNewButton.left = new FormAttachment(lblMakeSureYou, 6);
-               fd_btnBackup.right = new FormAttachment(100, -555);
+               fd_btnBackup.right = new FormAttachment(lblMakeSureYou, -6);
                FormData fd_lblMakeSureYou = new FormData();
-               fd_lblMakeSureYou.top = new FormAttachment(0, 10);
-               fd_lblMakeSureYou.left = new FormAttachment(btnBackup, 6);
-               fd_lblMakeSureYou.right = new FormAttachment(0, 541);
+               fd_lblMakeSureYou.left = new FormAttachment(0, 136);
+               fd_lblMakeSureYou.right = new FormAttachment(100, -144);
                fd_lblMakeSureYou.bottom = new FormAttachment(0, 92);
+               fd_lblMakeSureYou.top = new FormAttachment(0, 10);
                lblMakeSureYou.setLayoutData(fd_lblMakeSureYou);
                lblMakeSureYou.setText(Messages.MainWin_lblMakeSureYou_text);
-               fd_group_1.right = new FormAttachment(group, 0, SWT.RIGHT);
-               fd_group_1.left = new FormAttachment(0, 10);
-               group_1.setLayoutData(fd_group_1);
-
-               label = new Label(group_1, SWT.NONE);
-               label.setText("Always use a secure master-password, but don't forget it, you can not unlock\nyour FinalKey without it! Changing the password is risky, it can result in data-loss\nif the process is interrupted, you should take a backup before changing your\nmaster-password. Changing master-password takes a while as it re-encrypts accounts.");
-               FormData fd_label = new FormData();
-               fd_label.bottom = new FormAttachment(0, 79);
-               fd_label.top = new FormAttachment(0, 10);
-               fd_label.right = new FormAttachment(0, 675);
-               fd_label.left = new FormAttachment(0, 10);
-               label.setLayoutData(fd_label);
-
-               text_1 = new Text(group_1, SWT.BORDER | SWT.PASSWORD);
-               FormData fd_text_1 = new FormData();
-               fd_text_1.top = new FormAttachment(label, 6);
-               fd_text_1.right = new FormAttachment(0, 455);
-               fd_text_1.left = new FormAttachment(0, 149);
-               text_1.setLayoutData(fd_text_1);
-
-               text_2 = new Text(group_1, SWT.BORDER | SWT.PASSWORD);
-               FormData fd_text_2 = new FormData();
-               fd_text_2.top = new FormAttachment(text_1, 6);
-               fd_text_2.right = new FormAttachment(0, 455);
-               fd_text_2.left = new FormAttachment(0, 149);
-               text_2.setLayoutData(fd_text_2);
-
-               text_3 = new Text(group_1, SWT.BORDER | SWT.PASSWORD);
-               FormData fd_text_3 = new FormData();
-               fd_text_3.top = new FormAttachment(text_2, 6);
-               fd_text_3.right = new FormAttachment(text_1, 0, SWT.RIGHT);
-               fd_text_3.left = new FormAttachment(0, 149);
-               text_3.setLayoutData(fd_text_3);
-
-               label_1 = new Label(group_1, SWT.NONE);
-               label_1.setText("Current Pass");
-               label_1.setAlignment(SWT.RIGHT);
-               FormData fd_label_1 = new FormData();
-               fd_label_1.top = new FormAttachment(label, 12);
-               fd_label_1.right = new FormAttachment(text_1, -6);
-               fd_label_1.left = new FormAttachment(label, 0, SWT.LEFT);
-               label_1.setLayoutData(fd_label_1);
-
-               label_2 = new Label(group_1, SWT.NONE);
-               label_2.setText("New Pass");
-               label_2.setAlignment(SWT.RIGHT);
-               FormData fd_label_2 = new FormData();
-               fd_label_2.top = new FormAttachment(label_1, 12);
-               fd_label_2.right = new FormAttachment(text_2, -6);
-               fd_label_2.left = new FormAttachment(label, 0, SWT.LEFT);
-               label_2.setLayoutData(fd_label_2);
-
-               label_3 = new Label(group_1, SWT.NONE);
-               label_3.setText("Repeat");
-               label_3.setAlignment(SWT.RIGHT);
-               FormData fd_label_3 = new FormData();
-               fd_label_3.top = new FormAttachment(label_2, 12);
-               fd_label_3.right = new FormAttachment(text_3, -6);
-               fd_label_3.left = new FormAttachment(text_3, -139, SWT.LEFT);
-               label_3.setLayoutData(fd_label_3);
-
-               button = new Button(group_1, SWT.NONE);
-               button.setText("Re-encrypt");
-               FormData fd_button = new FormData();
-               fd_button.bottom = new FormAttachment(text_3, 0, SWT.BOTTOM);
-               fd_button.left = new FormAttachment(text_3, 6);
-               button.setLayoutData(fd_button);
+               fd_grpChangePassword.left = new FormAttachment(0, 10);
+               grpChangePassword.setLayoutData(fd_grpChangePassword);
+
+               lblAlwaysUseA = new Label(grpChangePassword, SWT.NONE);
+               lblAlwaysUseA.setText(Messages.MainWin_lblAlwaysUseA_text);
+               FormData fd_lblAlwaysUseA = new FormData();
+               fd_lblAlwaysUseA.bottom = new FormAttachment(0, 79);
+               fd_lblAlwaysUseA.top = new FormAttachment(0, 10);
+               fd_lblAlwaysUseA.right = new FormAttachment(0, 675);
+               fd_lblAlwaysUseA.left = new FormAttachment(0, 10);
+               lblAlwaysUseA.setLayoutData(fd_lblAlwaysUseA);
+
+               btnReencrypt = new Button(grpChangePassword, SWT.NONE);
+               btnReencrypt.setText(Messages.MainWin_btnReencrypt_text);
+               FormData fd_btnReencrypt = new FormData();
+               fd_btnReencrypt.left = new FormAttachment(lblAlwaysUseA, -102);
+               fd_btnReencrypt.bottom = new FormAttachment(100, -10);
+               fd_btnReencrypt.top = new FormAttachment(lblAlwaysUseA, 6);
+               fd_btnReencrypt.right = new FormAttachment(lblAlwaysUseA, 0, SWT.RIGHT);
+               btnReencrypt.setLayoutData(fd_btnReencrypt);
+               btnReencrypt.addSelectionListener( new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               shell.setEnabled(false);
+
+                               MessageBox d;
+                               d= new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO);
+                               d.setText("Danger ahead");
+                               d.setMessage("Changing your password will re-encrypt all accounts on your FinalKey.\nThis may take a while, and if the process is interrupted, data may be unaccessible.\nIt is highly recommended that you backup your FinalKey before proceeding.\nBe sure to remember the new password, your FinalKey can not be unlocked without it!\nDo you wish to continue ?");
+                               if( d.open() == SWT.YES )
+                               {
+                                       ChangePassPrompt p = new ChangePassPrompt(shell, shell.getStyle());
+                                       p.setText("Re-encrypt with new password");
+                                       p.open(false);
+                               } else {
+                                       d = new MessageBox(shell, SWT.ICON_INFORMATION );
+                                       d.setText("Aborted");
+                                       d.setMessage("Not changing the password.");
+                                       d.open();
+                               }
+                               shell.setEnabled(true);
+                       }
+               });
 
                grpFormat = new Group(composite, SWT.NONE);
+               fd_grpChangePassword.bottom = new FormAttachment(100, -236);
                grpFormat.setText(Messages.MainWin_grpFormat_text);
                FormData fd_grpFormat = new FormData();
-               fd_grpFormat.bottom = new FormAttachment(group_1, 69, SWT.BOTTOM);
-               fd_grpFormat.top = new FormAttachment(group_1, 6);
-               fd_grpFormat.right = new FormAttachment(group, 0, SWT.RIGHT);
+               fd_grpFormat.top = new FormAttachment(grpChangePassword, 6);
                fd_grpFormat.left = new FormAttachment(group, 0, SWT.LEFT);
+               fd_grpFormat.right = new FormAttachment(group, 0, SWT.RIGHT);
+               fd_grpFormat.bottom = new FormAttachment(100, -167);
                grpFormat.setLayoutData(fd_grpFormat);
 
                lblNewLabel = new Label(grpFormat, SWT.NONE);
                lblNewLabel.setBounds(10, 0, 366, 40);
                lblNewLabel.setText(Messages.MainWin_lblNewLabel_text_1);
 
-               btnNewButton_1 = new Button(grpFormat, SWT.NONE);
-               btnNewButton_1.setBounds(382, 10, 91, 26);
-               btnNewButton_1.setText(Messages.MainWin_btnNewButton_1_text);
+               btnFormat = new Button(grpFormat, SWT.NONE);
+               btnFormat.setBounds(594, 14, 81, 26);
+               btnFormat.setText(Messages.MainWin_btnNewButton_1_text);
+               btnFormat.addSelectionListener( new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               shell.setEnabled(false);
+
+                               MessageBox d;
+                               d= new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO);
+                               d.setText("Danger ahead");
+                               d.setMessage("Formatting your FinalKey overwrites all stored data, all accounts will be lost and unrecoverable. Are you sure you want to erase all data ?");
+                               if( d.open() == SWT.YES )
+                               {
+                                       ChangePassPrompt p = new ChangePassPrompt(shell, shell.getStyle());
+                                       p.setText("Format The FinalKey");
+                                       p.newBanner = txtBanner.getText();
+                                       p.newLayout = ""+(cmbLayout.getSelectionIndex()+1);
+                                       p.open(true);
+                               } else {
+                                       d = new MessageBox(shell, SWT.ICON_INFORMATION );
+                                       d.setText("Aborted");
+                                       d.setMessage("Format aborted.");
+                                       d.open();
+                               }
+                               shell.setEnabled(true);
+                       }
+               });
 
        }
        private void remThisFkTab() {
index 70f075f..1069fe3 100644 (file)
@@ -211,6 +211,10 @@ public class Messages extends NLS {
        public static String MainWin_btnNewButton_1_text;
        public static String MainWin_lblMakeSureYou_text;
        public static String MainWin_lblYouHaveNever_text;
+       public static String MainWin_lblAlwaysUseA_text;
+       public static String MainWin_grpChangePassword_text;
+       public static String MainWin_lblNewPassword_text;
+       public static String MainWin_btnReencrypt_text;
 
        static {
                // initialize resource bundle
index c5a0326..dfa76f4 100644 (file)
@@ -1,5 +1,5 @@
 #Eclipse modern messages class
-#Wed Mar 25 04:44:26 EET 2015
+#Wed Apr 01 10:37:47 EEST 2015
 MainWin_0=Already checking for updates...
 MainWin_1=accounts ready.
 MainWin_10=Search... (Ctrl+f)
@@ -45,6 +45,7 @@ MainWin_btnFormatMyFinalkey_text=Format my FinalKey
 MainWin_btnHideToTrayOnClose_toolTipText=Instead of closing the application completely when the close button is pressed, close only the main window and keep running in the System Tray icon.
 MainWin_btnNewButton_1_text=Format
 MainWin_btnNewButton_text=Restore
+MainWin_btnReencrypt_text=Re-Encrypt
 MainWin_btnSaveBanner_text=Save
 MainWin_btnSave_text=Save
 MainWin_btnShowAccountId_text=Show account id
@@ -52,7 +53,9 @@ MainWin_btnShowaccountsReady_text=Show "Accounts Ready" status popup after conne
 MainWin_group_1_text=Security
 MainWin_group_text=General settings
 MainWin_grpBackupAndRestore_text=Backup and Restore
+MainWin_grpChangePassword_text=Change password
 MainWin_grpFormat_text=Format
+MainWin_lblAlwaysUseA_text=Always use a secure password, but don't forget it, you can not unlock your FinalKey without it\!\nChanging the password can result in data-loss if the process is interrupted,\nYou should take a backup before changing your password.\nChanging master-password takes a while as it re-encrypts all accounts.
 MainWin_lblBannerName_text=Banner Name
 MainWin_lblF_text=Banner Text
 MainWin_lblKeyb_text=Keyb
@@ -62,6 +65,7 @@ MainWin_lblNewLabel_1_text=Current Pass
 MainWin_lblNewLabel_1_text_1=It's nice to have a backup so you don't lose everything\nif your Finalkey is lost or breaks.\n\nAlways keep your backups in a safe place.
 MainWin_lblNewLabel_text=Always use a secure master-password, but don't forget it, you can not unlock\nyour FinalKey without it\! Changing the password is risky, it can result in data-loss\nif the process is interrupted, you should take a backup before changing your\nmaster-password. Changing master-password takes a while as it re-encrypts accounts.
 MainWin_lblNewLabel_text_1=Delete everything and set a new password.\nThis makes all previous data unrecoverable.
+MainWin_lblNewPassword_text=New Password
 MainWin_lblNewPsw1_text=New Pass
 MainWin_lblRepeat_text=Repeat
 MainWin_lblY_text=Y