mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
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.
This commit is contained in:
parent
b004af07d0
commit
c4fdd1d9ee
1 changed files with 14 additions and 7 deletions
|
|
@ -9,7 +9,7 @@
|
||||||
#include "prmem.h"
|
#include "prmem.h"
|
||||||
#include "nsMsgSend.h"
|
#include "nsMsgSend.h"
|
||||||
#include "nsIIOService.h"
|
#include "nsIIOService.h"
|
||||||
#include "nsIHttpProtocolHandler.h"
|
#include "nsIXULAppInfo.h"
|
||||||
#include "nsMailHeaders.h"
|
#include "nsMailHeaders.h"
|
||||||
#include "nsMsgI18N.h"
|
#include "nsMsgI18N.h"
|
||||||
#include "nsINntpService.h"
|
#include "nsINntpService.h"
|
||||||
|
|
@ -357,14 +357,21 @@ nsresult mime_generate_headers(nsIMsgCompFields *fields,
|
||||||
finalHeaders->SetRawHeader(HEADER_X_MOZILLA_DRAFT_INFO, draftInfo, nullptr);
|
finalHeaders->SetRawHeader(HEADER_X_MOZILLA_DRAFT_INFO, draftInfo, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIHttpProtocolHandler> pHTTPHandler = do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &rv);
|
nsCOMPtr<nsIXULAppInfo> appInfo = do_GetService("@mozilla.org/xre/app-info;1");
|
||||||
if (NS_SUCCEEDED(rv) && pHTTPHandler)
|
if (appInfo) {
|
||||||
{
|
nsAutoCString userAgentString;
|
||||||
nsAutoCString userAgentString;
|
nsAutoCString userAgentName;
|
||||||
pHTTPHandler->GetUserAgent(userAgentString);
|
nsAutoCString userAgentVersion;
|
||||||
|
appInfo->GetName(userAgentName);
|
||||||
|
appInfo->GetVersion(userAgentVersion);
|
||||||
|
if (!userAgentName.IsEmpty() && !userAgentVersion.IsEmpty()) {
|
||||||
|
userAgentString += userAgentName;
|
||||||
|
userAgentString += '/';
|
||||||
|
userAgentString += userAgentVersion;
|
||||||
|
}
|
||||||
|
|
||||||
if (!userAgentString.IsEmpty())
|
if (!userAgentString.IsEmpty())
|
||||||
finalHeaders->SetUnstructuredHeader("User-Agent",
|
finalHeaders->SetUnstructuredHeader("X-Mailer",
|
||||||
NS_ConvertUTF8toUTF16(userAgentString));
|
NS_ConvertUTF8toUTF16(userAgentString));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue