浏览代码

Get it posting

Antony Male 8 年之前
父节点
当前提交
c04d00dad1
共有 1 个文件被更改,包括 59 次插入3 次删除
  1. 59 3
      installer/x64/installer-x64.iss

+ 59 - 3
installer/x64/installer-x64.iss

@@ -15,7 +15,8 @@
 #define AppDataFolder "SyncTrayzor"
 #define RunRegKey "Software\Microsoft\Windows\CurrentVersion\Run"
 #define DotNetInstallerExe "dotNet451Setup.exe"
-#define DonateUrl = "https://synctrayzor.antonymale.co.uk/donate"
+#define DonateUrl "https://synctrayzor.antonymale.co.uk/donate"
+#define SurveyUrl "https://requestb.in/yueovtyu"
 
 [Setup]
 AppId={{#AppId}
@@ -289,6 +290,47 @@ begin
   UninstallNextButton.Caption := 'Uninstall';
   // Make the "Uninstall" button break the ShowModal loop
   UninstallNextButton.ModalResult := mrOK;
+end;
+
+function SerializeBool(value: Boolean): String;
+begin
+  if value then
+  begin
+    Result := 'true';
+  end
+  else
+  begin
+    Result := 'false';
+  end
+end;
+
+function EscapeJsonString(value: String): String;
+var
+  c: Char;
+  i: Integer;
+begin
+  // http://www.jrsoftware.org/ishelp/index.php?topic=isxfunc_charlength
+  i := 1;
+  while i <= Length(value) do
+  begin
+    c := value[i];
+    if c = #10 then begin
+      Result := Result + '\n';
+    end else if c = #13 then begin
+      Result := Result + '\r';
+    end else if c = #9 then begin
+      Result := Result + '\t';
+    end else if Ord(c) < 32 then begin
+      Result := Result + Format('\x%.4x', [Ord(c)]);
+    end else if c = '"' then begin
+      Result := Result + '\"';
+    end else if c = '\' then begin
+      Result := Result + '\\'
+    end else begin
+      Result := Result + c;
+    end;
+    i := i + CharLength(value, i);
+  end;
 end;
 
 procedure InitializeUninstallProgressForm();
@@ -300,7 +342,8 @@ var
   CancelButtonModalResult: Integer;
   Checklist: TNewCheckListBox;
   CommentsText: TNewStaticText;
-  CommentsBox: TNewMemo;
+  CommentsBox: TNewMemo;
+  WinHttpReq: Variant;
 begin
   if not UninstallSilent then
   begin
@@ -368,7 +411,20 @@ begin
     CancelButtonModalResult := UninstallProgressForm.CancelButton.ModalResult;
     UninstallProgressForm.CancelButton.ModalResult := mrCancel;
 
-    if UninstallProgressForm.ShowModal = mrCancel then Abort;
+    if UninstallProgressForm.ShowModal = mrCancel then Abort;
+
+    WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
+    WinHttpReq.Open('POST', '{#SurveyUrl}', false);
+    WinHttpReq.Send('{' +
+      ' "wontWork": '+ SerializeBool(Checklist.Checked[0]) + 
+      ', "notWhatINeed": '+ SerializeBool(Checklist.Checked[1]) +
+      ', "preferResilio": '+ SerializeBool(Checklist.Checked[2]) +
+      ', "dontLikeSyncTrayzor": '+ SerializeBool(Checklist.Checked[3]) +
+      ', "other": '+ SerializeBool(Checklist.Checked[4]) +
+      ', "comments": "' + EscapeJsonString(CommentsBox.Text) + '"' +
+      ' }');
+
+    Abort;
 
     // Restore the standard page payout
     UninstallProgressForm.CancelButton.Enabled := CancelButtonEnabled;