feat(sync): QR des reglages sur le PC, Paste settings sur le telephone

Le poste genere le QR (DelphiZXingQRCode, Apache 2.0) depuis ses prefs :
URL + jeton, jamais le mot de passe de synchro. Le telephone lit le texte
copie par l'appareil photo et remplit les champs ; Save valide.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-09-17 18:03:00 +01:00
parent 05ff08886d
commit f817a6df43
10 changed files with 3913 additions and 1 deletions
+36
View File
@@ -341,6 +341,7 @@ type
/// que le proprietaire ne connaitrait pas.
procedure SetUnlockCode(const ANew: string);
procedure PushUnlockMode;
procedure PasteSyncSettings;
function PwdName: string;
/// Va chercher l'icone du site de l'entree ouverte, ou l'efface.
procedure SetEntryIcon(AFetch: Boolean);
@@ -1813,6 +1814,13 @@ begin
SetUnlockCode(TNetEncoding.URL.Decode(Param('c')));
end
// REGLAGES COLLES DEPUIS LE QR DU POSTE. L'appareil photo a lu le QR et
// copie son texte : {"pmsync":1,"u":URL,"t":JETON}. On remplit les champs
// des reglages SANS enregistrer - Save reste le geste qui valide - et on
// vide le presse-papiers, qui porte le jeton.
else if LAction = 'pastecfg' then
PasteSyncSettings
else if LAction = 'pinclear' then
ClearUnlockCode(TNetEncoding.URL.Decode(Param('c')))
@@ -3197,6 +3205,34 @@ begin
if HasLocalContainer then Result := 'vault password' else Result := 'sync password';
end;
procedure TForm8.PasteSyncSettings;
var
LDoc: TJSONObject;
LUrl, LTok: string;
begin
LUrl := '';
LTok := '';
LDoc := TJSONObject.ParseJSONValue(CurrentClipboard.Trim) as TJSONObject;
if LDoc <> nil then
try
if LDoc.GetValue<Integer>('pmsync', 0) = 1 then
begin
LUrl := LDoc.GetValue<string>('u', '');
LTok := LDoc.GetValue<string>('t', '');
end;
finally
LDoc.Free;
end;
if (LUrl = '') or (LTok = '') then
begin
WebCall('PM.toast("No settings in the clipboard - scan the QR on the PC and copy its text first")');
Exit;
end;
ClearClipboard;
Log('Sync settings pasted from the clipboard: token ' + Fingerprint(LTok));
WebCall(Format('PM.pasteConfig(%s, %s)', [JsArg(LUrl), JsArg(LTok)]));
end;
function TForm8.CachePwd: string;
begin
if HasLocalContainer then Result := FVaultPwd else Result := FSyncPwd;