diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-11-15 13:30:43 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-11-15 13:30:43 +0100 |
| commit | 7f89810e3c6ff92b0771ca11a817b82e081ccfa5 (patch) | |
| tree | b9dfae2f0e7c19e4aa4ba12af5a51fbf0a59e010 | |
| parent | f51fc44e0d479335b68650016b40813129039322 (diff) | |
| download | tuxcmd-7f89810e3c6ff92b0771ca11a817b82e081ccfa5.tar.xz | |
Connection Manager: Add ability not to save any passwords
| -rw-r--r-- | UConfig.pas | 11 | ||||
| -rw-r--r-- | UConnectionManager.pas | 36 | ||||
| -rw-r--r-- | UCore.pas | 12 | ||||
| -rw-r--r-- | UMain.pas | 2 |
4 files changed, 55 insertions, 6 deletions
diff --git a/UConfig.pas b/UConfig.pas index a23d4be..0ac1b21 100644 --- a/UConfig.pas +++ b/UConfig.pas @@ -113,6 +113,8 @@ var ConfPanelSep, ConfRowHeight, ConfRowHeightReal, ConfNumHistoryItems, ApplicationShuttingDown: boolean; ConfConnMgrActiveItem: integer; + ConfConnMgrDoNotSavePasswords, ConfConnMgrDoNotSynchronizeKeyring: boolean; + @@ -254,6 +256,8 @@ begin ConfQuickRenameSkipExt := True; ConfConnMgrActiveItem := 0; ConfRightClickSelect := False; + ConfConnMgrDoNotSavePasswords := False; + ConfConnMgrDoNotSynchronizeKeyring := False; // Setup default values for colors @@ -936,6 +940,8 @@ begin for i := 0 to Sections.Count - 1 do if Sections[i] = '__General' then begin ConfConnMgrActiveItem := IniFile.ReadInteger('__General', 'ConnMgrActiveItem', ConfConnMgrActiveItem); + ConfConnMgrDoNotSavePasswords := IniFile.ReadBool('__General', 'ConnMgrDoNotSavePasswords', ConfConnMgrDoNotSavePasswords); + ConfConnMgrDoNotSynchronizeKeyring := IniFile.ReadBool('__General', 'ConnMgrDoNotSynchronizeKeyring', ConfConnMgrDoNotSynchronizeKeyring); end else begin Item := TConnMgrItem.Create; with Item do begin @@ -976,6 +982,8 @@ begin IniFile := TMyIniFile.Create(s, False); try try IniFile.WriteInteger('__General', 'ConnMgrActiveItem', ConfConnMgrActiveItem); + IniFile.WriteBool('__General', 'ConnMgrDoNotSavePasswords', ConfConnMgrDoNotSavePasswords); + IniFile.WriteBool('__General', 'ConnMgrDoNotSynchronizeKeyring', ConfConnMgrDoNotSynchronizeKeyring); if ConnectionMgrList.Count > 0 then for i := 0 to ConnectionMgrList.Count - 1 do with TConnMgrItem(ConnectionMgrList[i]) do begin @@ -984,7 +992,8 @@ begin IniFile.WriteString(SectionTitle, 'ServiceType', ServiceType); IniFile.WriteString(SectionTitle, 'Server', Server); IniFile.WriteString(SectionTitle, 'Username', Username); - IniFile.WriteString(SectionTitle, 'Password', Password); + if not ConfConnMgrDoNotSavePasswords then IniFile.WriteString(SectionTitle, 'Password', Password) + else IniFile.WriteString(SectionTitle, 'Password', ''); IniFile.WriteString(SectionTitle, 'TargetDir', TargetDir); IniFile.WriteString(SectionTitle, 'PluginID', PluginID); end; diff --git a/UConnectionManager.pas b/UConnectionManager.pas index 86f3bd7..3703b02 100644 --- a/UConnectionManager.pas +++ b/UConnectionManager.pas @@ -40,6 +40,7 @@ type ButtonBox: TGTKVButtonBox; ActionButtonBox: TGTKHButtonBox; ConnectButton, CloseButton: TGTKButton; + DoNotSavePasswordsCheckBox, DoNotSynchronizeKeyringCheckBox: TGTKCheckButton; procedure FormCreate(Sender: TObject); override; procedure ListViewSelectionChanged(Sender: TObject); procedure FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean); @@ -74,7 +75,7 @@ procedure TFConnectionManager.FormCreate(Sender: TObject); var Column: TGTKTreeViewColumn; begin ConnectedEngine := nil; - SetDefaultSize(550, 450); + SetDefaultSize(650, 500); Caption := LANGConnMgr_Caption; Buttons := []; ShowSeparator := False; @@ -126,7 +127,7 @@ begin Column := ListView.Columns.Add; Column.AddAttribute('text', 1); Column.Resizable := True; - Column.FixedWidth := 200; + Column.FixedWidth := 230; Column.SizingMode := smFixed; Column.Caption := LANGConnMgr_NameColumn; Column.Clickable := True; @@ -165,7 +166,14 @@ begin ButtonBox.AddControl(EditButton); ButtonBox.AddControl(RemoveButton); + DoNotSavePasswordsCheckBox := TGTKCheckButton.CreateWithLabel(Self, '_Do not store passwords internally (but still use gnome-keyring)'); + DoNotSavePasswordsCheckBox.Tooltip := 'By checking this option on, Tux Commander will never save passwords into its connection list. Due to the GVFS nature, gnome-keyring will still be used to retrieve stored passwords from your desktop session.'; + DoNotSynchronizeKeyringCheckBox := TGTKCheckButton.CreateWithLabel(Self, 'Do not synchronize passwords to _gnome-keyring'); + DoNotSynchronizeKeyringCheckBox.Tooltip := 'Don''t tell gnome-keyring to save any passwords.'; + ListViewTable.AddControlEx(0, 1, 3, 5, ListViewScrolledWindow, [taoExpand, taoFill], [taoExpand, taoFill], 0, 5); + ListViewTable.AddControlEx(0, 6, 3, 1, DoNotSavePasswordsCheckBox, [taoExpand, taoFill], [taoShrink], 10, 0); + ListViewTable.AddControlEx(0, 7, 3, 1, DoNotSynchronizeKeyringCheckBox, [taoExpand, taoFill], [taoShrink], 10, 2); ListViewTable.AddControlEx(3, 2, 1, 3, ButtonBox, [taoShrink, taoFill], [taoShrink], 5, 5); { ListViewTable.AddControlEx(3, 2, 1, 1, AddConnectionButton, [taoShrink, taoFill], [taoShrink], 5, 5); ListViewTable.AddControlEx(3, 3, 1, 1, EditButton, [taoShrink, taoFill], [taoShrink], 5, 5); @@ -329,6 +337,8 @@ begin end; if (ConfConnMgrActiveItem < 0) or (ConfConnMgrActiveItem > ConnectionMgrList.Count) then ConfConnMgrActiveItem := 0; + DoNotSavePasswordsCheckBox.Checked := ConfConnMgrDoNotSavePasswords; + DoNotSynchronizeKeyringCheckBox.Checked := ConfConnMgrDoNotSynchronizeKeyring; end; @@ -373,7 +383,15 @@ begin Inc(ConnMgr.FVFSAskPasswordTry); if ConnMgr.AFRemoteWait <> nil then DialogParent := ConnMgr.AFRemoteWait.FWidget else DialogParent := ConnMgr.FWidget; - flags := flags or VFS_ASK_PASSWORD_SAVE_INTERNAL; + + if not ConnMgr.DoNotSavePasswordsCheckBox.Checked then + flags := flags or VFS_ASK_PASSWORD_SAVE_INTERNAL; + + // Disable password saving if requested + if ConnMgr.DoNotSynchronizeKeyringCheckBox.Checked then begin + flags := flags and (not VFS_ASK_PASSWORD_SAVING_SUPPORTED); + if password_save <> nil then password_save^ := VFS_PASSWORD_SAVE_NEVER; + end; end; // First pass, supply stored password if we have one @@ -384,7 +402,10 @@ begin DebugMsg(['(II) vfs_ask_password_callback: Supplying stored password from Connection Manager']); Result := True; password^ := g_strdup(PChar(ConnMgr.FActiveConnInfo.Password)); - if (password_save <> nil) { and ConfGnomeKeyringEnabled} then password_save^ := VFS_PASSWORD_SAVE_PERMANENTLY; + if password_save <> nil then + if ConnMgr.DoNotSynchronizeKeyringCheckBox.Checked + then password_save^ := VFS_PASSWORD_SAVE_NEVER + else password_save^ := VFS_PASSWORD_SAVE_PERMANENTLY; end else begin // Show password dialog and continue in loop Result := HandleVFSAskPasswordCallback(DialogParent, AMessage, default_user, default_domain, default_password, flags, username, password, anonymous, domain, password_save); @@ -392,13 +413,18 @@ begin ConnMgr.FSilenceError := Result = False; // Save password back to Connection Manager if Result and (password_save <> nil) and (password_save^ = VFS_PASSWORD_SAVE_PERMANENTLY) and - (ConnMgr.FActiveConnInfo <> nil) and (password <> nil) and (strlen(password^) > 0) then + (ConnMgr.FActiveConnInfo <> nil) and (password <> nil) and (strlen(password^) > 0) and + (not ConnMgr.DoNotSavePasswordsCheckBox.Checked) then begin DebugMsg(['(II) vfs_ask_password_callback: Saving password to Connection Manager']); ConnMgr.FActiveConnInfo.Password := password^; end; end; end; + + // Strip password saving if requested + if (ConnMgr is TFConnectionManager) and ConnMgr.DoNotSynchronizeKeyringCheckBox.Checked and (password_save <> nil) then + password_save^ := VFS_PASSWORD_SAVE_NEVER; end; procedure TFConnectionManager.DoConnect; @@ -320,6 +320,14 @@ begin def_pass := default_password; + // Disable password saving if requested + if ConfConnMgrDoNotSynchronizeKeyring then begin + flags := flags and (not VFS_ASK_PASSWORD_SAVING_SUPPORTED); + if password_save <> nil then password_save^ := VFS_PASSWORD_SAVE_NEVER; + end; + if ConfConnMgrDoNotSavePasswords then + flags := flags and (not VFS_ASK_PASSWORD_SAVE_INTERNAL); + // Use stored password, if previously set if ((flags and VFS_ASK_PASSWORD_ARCHIVE_MODE) = VFS_ASK_PASSWORD_ARCHIVE_MODE) and (password <> nil) and (Thread.AEngine is TVFSEngine) and (Length((Thread.AEngine as TVFSEngine).Password) > 0) then @@ -373,6 +381,10 @@ begin (Thread.AEngine as TVFSEngine).Password := string(password^); (Thread.AEngine as TVFSEngine).PasswordUsed := True; end; + + // Strip password saving if requested + if ConfConnMgrDoNotSynchronizeKeyring and (password_save <> nil) then + password_save^ := VFS_PASSWORD_SAVE_NEVER; end; function vfs_progress_callback(position, max: Int64; user_data: Pointer): LongBool; cdecl; @@ -6019,6 +6019,8 @@ begin else FConnectionManager.SourcePanelEngine := RightPanelEngine; b := FConnectionManager.Run = mbOK; if FConnectionManager.ListView.Selected <> nil then ConfConnMgrActiveItem := FConnectionManager.ListView.Selected.Index; + ConfConnMgrDoNotSavePasswords := FConnectionManager.DoNotSavePasswordsCheckBox.Checked; + ConfConnMgrDoNotSynchronizeKeyring := FConnectionManager.DoNotSynchronizeKeyringCheckBox.Checked; WriteConnections; // Save connection manager data if b and (FConnectionManager.ConnectedEngine <> nil) then begin |
