summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Andrews <athenian200@outlook.com>2023-11-14 23:47:34 -0600
committerJeremy Andrews <athenian200@outlook.com>2023-11-14 23:47:34 -0600
commitd8bc8410b02b53ea119193f32522a63678fdf999 (patch)
treeca0556056ed42efada3e956c0efa0da9522cd259
parentf1f7466a72f963807e54123fb9b5e2d2ec6143b1 (diff)
downloaduxp-d8bc8410b02b53ea119193f32522a63678fdf999.tar.gz
Issue #1312 - Switch to X-Mailer, and pull from AppInfo instead of HTTP headers.
I've been thinking about this issue, and ultimately it's just correcting a mistake Mozilla made that no consumer of UXP's MailNews ever complained about before, so I think it's reasonable to fix the default behavior first, and then let others complain before I start worrying about prefs or ifdefs. One thing at a time.
-rw-r--r--mailnews/compose/src/nsMsgCompUtils.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/mailnews/compose/src/nsMsgCompUtils.cpp b/mailnews/compose/src/nsMsgCompUtils.cpp
index 6632e3257c..403b3c444d 100644
--- a/mailnews/compose/src/nsMsgCompUtils.cpp
+++ b/mailnews/compose/src/nsMsgCompUtils.cpp
@@ -9,7 +9,7 @@
#include "prmem.h"
#include "nsMsgSend.h"
#include "nsIIOService.h"
-#include "nsIHttpProtocolHandler.h"
+#include "nsIXULAppInfo.h"
#include "nsMailHeaders.h"
#include "nsMsgI18N.h"
#include "nsINntpService.h"
@@ -357,14 +357,21 @@ nsresult mime_generate_headers(nsIMsgCompFields *fields,
finalHeaders->SetRawHeader(HEADER_X_MOZILLA_DRAFT_INFO, draftInfo, nullptr);
}
- nsCOMPtr<nsIHttpProtocolHandler> pHTTPHandler = do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &rv);
- if (NS_SUCCEEDED(rv) && pHTTPHandler)
- {
- nsAutoCString userAgentString;
- pHTTPHandler->GetUserAgent(userAgentString);
+ nsCOMPtr<nsIXULAppInfo> appInfo = do_GetService("@mozilla.org/xre/app-info;1");
+ if (appInfo) {
+ nsAutoCString userAgentString;
+ nsAutoCString userAgentName;
+ nsAutoCString userAgentVersion;
+ appInfo->GetName(userAgentName);
+ appInfo->GetVersion(userAgentVersion);
+ if (!userAgentName.IsEmpty() && !userAgentVersion.IsEmpty()) {
+ userAgentString += userAgentName;
+ userAgentString += '/';
+ userAgentString += userAgentVersion;
+ }
if (!userAgentString.IsEmpty())
- finalHeaders->SetUnstructuredHeader("User-Agent",
+ finalHeaders->SetUnstructuredHeader("X-Mailer",
NS_ConvertUTF8toUTF16(userAgentString));
}