浏览代码

Avoiding empty lines at the end of the message from update server, when no update information is available

Source commit: f5ff281251ceda62ef87541982a5c7c2beab4865
Martin Prikryl 3 年之前
父节点
当前提交
b7bb806517
共有 5 个文件被更改,包括 18 次插入12 次删除
  1. 3 3
      source/forms/Preferences.cpp
  2. 0 1
      source/resource/TextsWin.h
  3. 0 1
      source/resource/TextsWin1.rc
  4. 14 6
      source/windows/Setup.cpp
  5. 1 1
      source/windows/Setup.h

+ 3 - 3
source/forms/Preferences.cpp

@@ -2554,10 +2554,10 @@ void __fastcall TPreferencesDialog::UpdatesAuthenticationEmailEditExit(TObject *
           QueryUpdates(Updates);
         }
 
-        UnicodeString AuthenticationError = Updates.Results.AuthenticationError;
-        if (!AuthenticationError.IsEmpty())
+        if (!Updates.Results.AuthenticationError.IsEmpty())
         {
-          AuthenticationError = FormatUpdatesMessage(AuthenticationError, Updates);
+          UnicodeString AuthenticationError;
+          FormatUpdatesMessage(AuthenticationError, Updates.Results.AuthenticationError, Updates);
           if (HasParagraphs(AuthenticationError))
           {
             AuthenticationError = MainInstructionsFirstParagraph(AuthenticationError);

+ 0 - 1
source/resource/TextsWin.h

@@ -191,7 +191,6 @@
 #define CUSTOM_COMMAND_GREP_PATTERN 1472
 #define DIRECTORY_READING_PROGRESS 1473
 #define QUEUE_LISTING           1474
-#define UPDATE_MESSAGE          1475
 #define UPGRADE_BUTTON          1476
 #define COPY_PARAM_AUTOSELECTED 1478
 #define COPY_PARAM_DEFAULT_CUSTOM 1479

+ 0 - 1
source/resource/TextsWin1.rc

@@ -197,7 +197,6 @@ BEGIN
         CUSTOM_COMMAND_GREP_PATTERN, "&Search for pattern:"
         DIRECTORY_READING_PROGRESS, "%d Reading directory"
         QUEUE_LISTING, "Listing..."
-        UPDATE_MESSAGE, "\n \n%s"
         UPGRADE_BUTTON, "&Upgrade"
         COPY_PARAM_AUTOSELECTED, "Transfer settings preset '%s' was automatically selected."
         COPY_PARAM_DEFAULT_CUSTOM, "Returned back to transfer settings preset '%s'."

+ 14 - 6
source/windows/Setup.cpp

@@ -1124,7 +1124,8 @@ static void __fastcall DoQueryUpdates(bool CollectUsage)
   }
 }
 //---------------------------------------------------------------------------
-UnicodeString __fastcall FormatUpdatesMessage(const UnicodeString & AMessage, const TUpdatesConfiguration & Updates)
+void FormatUpdatesMessage(
+  UnicodeString & UpdatesMessage, const UnicodeString & AMessage, const TUpdatesConfiguration & Updates)
 {
   UnicodeString Message = AMessage;
   Message = ReplaceStr(Message, "%UPDATE_UNAUTHORIZED%", LoadStr(UPDATE_UNAUTHORIZED));
@@ -1138,7 +1139,16 @@ UnicodeString __fastcall FormatUpdatesMessage(const UnicodeString & AMessage, co
   Message = ReplaceStr(Message, "%UPDATE_MISSING_ADDRESS%", Buf);
   Message = ReplaceStr(Message, "%UPDATE_TOO_LOW%", LoadStr(UPDATE_TOO_LOW));
   Message = ReplaceStr(Message, L"|", L"\n");
-  return Message;
+
+  if (!Message.IsEmpty())
+  {
+    UpdatesMessage = TrimRight(UpdatesMessage);
+    if (!UpdatesMessage.IsEmpty())
+    {
+      UpdatesMessage += L"\n \n";
+    }
+    UpdatesMessage += Message;
+  }
 }
 //---------------------------------------------------------------------------
 void __fastcall GetUpdatesMessage(UnicodeString & Message, bool & New,
@@ -1188,14 +1198,12 @@ void __fastcall GetUpdatesMessage(UnicodeString & Message, bool & New,
 
     if (!Updates.Results.Message.IsEmpty())
     {
-      Message +=
-        FMTLOAD(UPDATE_MESSAGE, (FormatUpdatesMessage(Updates.Results.Message, Updates)));
+      FormatUpdatesMessage(Message, Updates.Results.Message, Updates);
     }
 
     if (!Updates.Results.AuthenticationError.IsEmpty() && !IsUWP())
     {
-      Message +=
-        FMTLOAD(UPDATE_MESSAGE, (FormatUpdatesMessage(Updates.Results.AuthenticationError, Updates)));
+      FormatUpdatesMessage(Message, Updates.Results.AuthenticationError, Updates);
     }
     Type = (Updates.Results.Critical ? qtWarning : qtInformation);
   }

+ 1 - 1
source/windows/Setup.h

@@ -14,7 +14,7 @@ THttp * __fastcall CreateHttp();
 void __fastcall GetUpdatesMessage(UnicodeString & Message, bool & New, TQueryType & Type, bool Force);
 bool __fastcall CheckForUpdates(bool CachedResults);
 bool __fastcall QueryUpdates(TUpdatesConfiguration & Updates);
-UnicodeString __fastcall FormatUpdatesMessage(const UnicodeString & Message, const TUpdatesConfiguration & Updates);
+void FormatUpdatesMessage(UnicodeString & UpdatesMessage, const UnicodeString & AMessage, const TUpdatesConfiguration & Updates);
 void __fastcall EnableAutomaticUpdates();
 void __fastcall RegisterForDefaultProtocols();
 void __fastcall UnregisterForProtocols();