Advertisement
RandomClear

Explicit send consent before sending

Feb 28th, 2018
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.95 KB | None | 0 0
  1. // This sample will show you how you can explicitly ask user to confirm sending.
  2. // This may be required by some data privacy standards.
  3.  
  4. uses
  5.   EDialog, // for RegisterDialogClassFirst
  6.   EDialogWinAPIMSClassic, // for TMSClassicDialog
  7.   EDialogWinAPIEurekaLogDetailed, // for TEurekaLogDetailedDialog
  8.   ETypes; // for TResponse
  9.  
  10. type
  11.   // Override sending report in all dialog classes which are used in application
  12.   TMSClassicDialog = class(EDialogWinAPIMSClassic.TMSClassicDialog)
  13.     function SendBugReportInternal: TResponse; override;
  14.   end;
  15.  
  16.   TEurekaLogDetailedDialog = class(EDialogWinAPIEurekaLogDetailed.TEurekaLogDetailedDialog)
  17.     function SendBugReportInternal: TResponse; override;
  18.   end;
  19.  
  20. function TMSClassicDialog.SendBugReportInternal: TResponse;
  21. begin
  22.   // Ask consent first
  23.   if Application.MessageBox('Do you want to send bug report with your private data?',
  24.      'Send consent', MB_YESNO or MB_DEFBUTTON2) <> mrYes then
  25.   begin
  26.     // If user does not agree to send report - indicate send was cancelled
  27.     Finalize(Result);
  28.     FillChar(Result, SizeOf(Result), 0);
  29.     Result.SendResult := srCancelled;
  30.     Result.ErrorMessage := 'Send consent was not given';
  31.   end
  32.   else
  33.     // ...otherwise (user agrees) - do a real send
  34.     Result := inherited SendBugReportInternal;
  35. end;
  36.  
  37. function TEurekaLogDetailedDialog.SendBugReportInternal: TResponse;
  38. begin
  39.   if Application.MessageBox('Do you want to send bug report with this data?',
  40.      'Send consent', MB_YESNO or MB_DEFBUTTON2) <> mrYes then
  41.   begin
  42.     Finalize(Result);
  43.     FillChar(Result, SizeOf(Result), 0);
  44.     Result.SendResult := srCancelled;
  45.     Result.ErrorMessage := 'Send consent was not given';
  46.   end
  47.   else
  48.     Result := inherited SendBugReportInternal;
  49. end;
  50.  
  51. initialization
  52.   // Don't forget to register your dialog classes to override EurekaLog's ones
  53.   RegisterDialogClassFirst(TMSClassicDialog);
  54.   RegisterDialogClassFirst(TEurekaLogDetailedDialog);
  55. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement