summaryrefslogtreecommitdiff
path: root/UMain.pas
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2008-10-28 16:51:52 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2008-10-28 16:51:52 +0100
commita67cd9193a6ac04d34c92c1a817fb0f5e44af30f (patch)
tree888227edebb4844efb01cd70bcbfc459b09d2a56 /UMain.pas
parent4234ca950044c27a1b2fcc92f45d816ef217487f (diff)
downloadtuxcmd-a67cd9193a6ac04d34c92c1a817fb0f5e44af30f.tar.xz
Password callback support from all VFS modulesv0.6.54
Cleanup, remove unused dialogs
Diffstat (limited to 'UMain.pas')
-rw-r--r--UMain.pas95
1 files changed, 27 insertions, 68 deletions
diff --git a/UMain.pas b/UMain.pas
index e214947..a808667 100644
--- a/UMain.pas
+++ b/UMain.pas
@@ -236,7 +236,6 @@ type
procedure NewTabInternal(LeftPanel: boolean; _Engine: TPanelEngine; _Path: string; NewTabPosition: integer);
procedure CopyFilenamesToClipboard(FullPaths, LeftPanel: boolean);
function HandleRunFromArchive(var APath: string; Engine: TPanelEngine; Command, FileTypeDesc: string; BypassDialog: boolean): boolean;
- function HandleSetPassword(Engine: TPanelEngine): boolean;
function HandleKey(Key: Word; Shift: TShiftState; LeftPanel: boolean): boolean;
function IsEditing(AListView: TGTKListView): boolean;
function PanelFindEditableWidget(AListView: TGTKListView): PGtkWidget;
@@ -258,7 +257,7 @@ uses ULibc,
UFileTypeSettings, UFileAssoc, UChmod, UChown, USymlink,
UPreferences, UViewer, UToolTips, UMounterPrefs, UColumns,
UTestPlugin, UConnectionManager, USearch, UProperties,
- URemoteWait, URunFromVFS, USetPassword, uVFSprototypes;
+ URemoteWait, URunFromVFS, uVFSprototypes;
@@ -1702,7 +1701,7 @@ var ListView: TGTKListView;
Engine: TPanelEngine;
s, ss: string;
i, Sel: integer;
- b, bb: boolean;
+ b: boolean;
tt: TDateTime;
DataList, DirList: TList;
SelectedFiles: TStringList;
@@ -1775,6 +1774,7 @@ var ListView: TGTKListView;
OpenDirThread.VFSAskPassword_Message,
OpenDirThread.VFSAskPassword_default_user,
OpenDirThread.VFSAskPassword_default_domain,
+ OpenDirThread.VFSAskPassword_default_password,
OpenDirThread.VFSAskPassword_flags,
OpenDirThread.VFSAskPassword_username,
OpenDirThread.VFSAskPassword_password,
@@ -1834,29 +1834,14 @@ begin
DebugMsg(['TFMain.ChangingDir: Creating thread...']);
DoThread;
- bb := OpenDirThread.VFSOpenResult = 0;
- if OpenDirThread.VFSOpenResult <> 0 then begin
- DebugMsg(['(II) TFMain.ChangingDir: OpenDirThread.VFSOpenResult <> 0']);
- if OpenDirThread.VFSOpenResult = cVFS_BadPassword then begin
- // Handle password
- if not HandleSetPassword(OpenDirThread.xEngine) then Exit;
- ss := OpenDirThread.xEngine.Password;
- if Assigned(OpenDirThread.xEngine) then OpenDirThread.xEngine.Free;
- DebugMsg(['TFMain.ChangingDir: Freeing thread...']);
- OpenDirThread.Free;
- OpenDirThread := TOpenDirThread.Create;
- DebugMsg(['TFMain.ChangingDir: Creating thread...']);
- OpenDirThread.Password := ss;
- DoThread;
- bb := OpenDirThread.VFSOpenResult = 0;
- end;
- end;
if Plugin <> nil then begin
HiliString1 := '';
HiliString2 := '';
end;
- if not bb then begin
- Application.MessageBox(LANGCouldntOpenURIArchive, [mbOK], mbError, mbOK, mbOK);
+ if OpenDirThread.VFSOpenResult <> 0 then begin
+ // Silence the error if password dialog has been cancelled
+ if not OpenDirThread.VFSCallbackCancelled then
+ Application.MessageBox(LANGCouldntOpenURIArchive, [mbOK], mbError, mbOK, mbOK);
DebugMsg(['TFMain.ChangingDir: Freeing thread...']);
OpenDirThread.Free;
end else
@@ -2649,12 +2634,6 @@ begin
end;
DebugMsg(['TFMain.DoCopyMove: NewPath = "', NewPath, '"']);
- // Handle password in archives
- if (CurrentEngine is TVFSEngine) and (CurrentEngine as TVFSEngine).GetPasswordRequired and (Length((CurrentEngine as TVFSEngine).Password) < 1) then
- if not HandleSetPassword(CurrentEngine) then Exit;
- if (OppositeEngine is TVFSEngine) and (OppositeEngine as TVFSEngine).GetPasswordRequired and (Length((OppositeEngine as TVFSEngine).Password) < 1) then
- if not HandleSetPassword(OppositeEngine) then Exit;
-
NextItem1 := ''; NextItem2 := '';
FindNextSelected(ListView, DataList, NextItem1, NextItem2);
DebugMsg(['TFMain.DoCopyMove: FindNextSelected, NextItem1 = "', NextItem1, '", NextItem2 = "', NextItem2, '"']);
@@ -3969,11 +3948,7 @@ begin
Break;
end;
- // Handle password
- if (Engine is TVFSEngine) and TVFSEngine(Engine).GetPasswordRequired and (Length(TVFSEngine(Engine).Password) < 1) then
- if not HandleSetPassword(Engine) then Exit;
-
- if AFile <> '' then
+ if AFile <> '' then
try
FChmod := TFChmod.Create(Self);
Stat := Engine.GetFileInfoSL(IncludeTrailingPathDelimiter(Engine.Path) + AFile);
@@ -4069,11 +4044,7 @@ begin
Break;
end;
- // Handle password
- if (Engine is TVFSEngine) and TVFSEngine(Engine).GetPasswordRequired and (Length(TVFSEngine(Engine).Password) < 1) then
- if not HandleSetPassword(Engine) then Exit;
-
- if AFile <> '' then
+ if AFile <> '' then
try
FChown := TFChown.Create(Self);
Stat := Engine.GetFileInfoSL(IncludeTrailingPathDelimiter(Engine.Path) + AFile);
@@ -4148,10 +4119,6 @@ begin
then s2 := IncludeTrailingPathDelimiter(EngineOpposite.Path) + PDataItem(AListView.Selected.Data)^.FName
else s2 := '';
- // Handle password
- if (Engine is TVFSEngine) and TVFSEngine(Engine).GetPasswordRequired and (Length(TVFSEngine(Engine).Password) < 1) then
- if not HandleSetPassword(Engine) then Exit;
-
if CreateSymlink(s1, s2, Engine) then begin
DoRefresh(LeftPanel, True, True);
DoRefresh(not LeftPanel, True, True);
@@ -4187,10 +4154,6 @@ begin
Exit;
end;
- // Handle password
- if (Engine is TVFSEngine) and TVFSEngine(Engine).GetPasswordRequired and (Length(TVFSEngine(Engine).Password) < 1) then
- if not HandleSetPassword(Engine) then Exit;
-
if EditSymlink(IncludeTrailingPathDelimiter(Engine.Path) + PDataItem(AListView.Selected.Data)^.FName, Engine) then begin
DoRefresh(LeftPanel, True, True);
DoRefresh(not LeftPanel, True, True);
@@ -5276,13 +5239,13 @@ begin
FTestPlugin := TFTestPlugin.Create(Self);
if (FTestPlugin.Run = mbOK) and (PluginList.Count > 0) then begin
Engine := TVFSEngine.Create(PluginList[FTestPlugin.PluginOptionMenu.ItemIndex]);
- if not Engine.VFSOpenURI(FTestPlugin.CommandEntry.Text, nil, nil, nil) then begin
+ if not Engine.VFSOpenURI(FTestPlugin.CommandEntry.Text, nil, nil, nil, nil) then begin
Application.MessageBox(LANGCouldntOpenURI, [mbOK], mbError, mbOK, mbOK);
Exit;
end;
b := True;
- if not FTestPlugin.AnonymousCheckButton.Checked then
- b := HandleLogin(FTestPlugin, Engine, FTestPlugin.UserEntry.Text, FTestPlugin.PasswordEntry.Text);
+{ if not FTestPlugin.AnonymousCheckButton.Checked then
+ b := HandleLogin(FTestPlugin, Engine, FTestPlugin.UserEntry.Text, FTestPlugin.PasswordEntry.Text); }
if b then begin
if LeftLastFocused then LeftPanelEngine := Engine
else RightPanelEngine := Engine;
@@ -6250,10 +6213,6 @@ begin
end else Res := mbYes;
if Res in [mbYes, mbNo] then begin
Result := False;
- // Handle password
- if (Engine is TVFSEngine) and TVFSEngine(Engine).GetPasswordRequired and (Length(TVFSEngine(Engine).Password) < 1) then
- if not HandleSetPassword(Engine) then Exit;
-
if Res = mbYes then DebugMsg(['(II) HandleRunFromArchive: Selected extract and execute single item'])
else DebugMsg(['(II) HandleRunFromArchive: Selected extract all and execute']);
s := IncludeTrailingPathDelimiter(ConfTempPath) + 'tuxcmd-XXXXXX';
@@ -6335,30 +6294,30 @@ begin
end;
procedure TFMain.PasswordButtonClick(Sender: TObject);
+var Engine: TPanelEngine;
+ Password: PChar;
begin
- if Sender = LeftPasswordButton then HandleSetPassword(LeftPanelEngine) else
- if Sender = RightPasswordButton then HandleSetPassword(RightPanelEngine);
-end;
+ if Sender = LeftPasswordButton then Engine := LeftPanelEngine else
+ if Sender = RightPasswordButton then Engine := RightPanelEngine
+ else Exit;
-function TFMain.HandleSetPassword(Engine: TPanelEngine): boolean;
-begin
- Result := False;
if not (Engine is TVFSEngine) then Exit;
try
- FSetPassword := TFSetPassword.Create(Self);
- FSetPassword.Entry.Text := TVFSEngine(Engine).Password;
- if Length(FSetPassword.Entry.Text) > 0 then FSetPassword.Entry.SelectAll;
- Result := FSetPassword.Run = mbOK;
- if Result then TVFSEngine(Engine).Password := FSetPassword.Entry.Text;
- FSetPassword.Free;
+ Password := nil;
+ if HandleVFSAskPasswordCallback(FWidget, PChar('The archive is encrypted and requires password'),
+ nil, nil, PChar(TVFSEngine(Engine).Password),
+ VFS_ASK_PASSWORD_NEED_PASSWORD or VFS_ASK_PASSWORD_ARCHIVE_MODE,
+ nil, @Password, nil, nil, nil) then
+ if Password <> nil then begin
+ TVFSEngine(Engine).Password := string(Password);
+ TVFSEngine(Engine).PasswordUsed := False;
+ g_free(Password);
+ end;
except
on E: Exception do DebugMsg(['*** Exception raised in FMain.HandleSetPassword: (', E.ClassName, '): ', E.Message]);
end;
end;
-
-
-
end.