2015-02-12 12:16:25 -03:00
|
|
|
// Aseprite
|
2021-11-02 14:18:14 -03:00
|
|
|
// Copyright (C) 2019-2021 Igara Studio S.A.
|
2017-06-29 13:03:28 -03:00
|
|
|
// Copyright (C) 2001-2017 David Capello
|
2015-02-12 12:16:25 -03:00
|
|
|
//
|
2016-08-26 17:02:58 -03:00
|
|
|
// This program is distributed under the terms of
|
|
|
|
// the End-User License Agreement for Aseprite.
|
2011-07-26 23:25:02 -03:00
|
|
|
|
2013-08-05 21:20:19 -03:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2011-07-26 23:25:02 -03:00
|
|
|
#include "config.h"
|
2013-08-05 21:20:19 -03:00
|
|
|
#endif
|
2011-07-26 23:25:02 -03:00
|
|
|
|
2020-03-16 10:29:58 -03:00
|
|
|
#include "updater/user_agent.h"
|
2021-11-02 14:18:14 -03:00
|
|
|
|
|
|
|
#include "base/platform.h"
|
2020-03-16 10:29:58 -03:00
|
|
|
#include "ver/info.h"
|
|
|
|
|
2011-07-26 23:25:02 -03:00
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
namespace updater {
|
|
|
|
|
|
|
|
std::string getUserAgent()
|
|
|
|
{
|
2021-11-02 14:18:14 -03:00
|
|
|
base::Platform p = base::get_platform();
|
2011-07-26 23:25:02 -03:00
|
|
|
std::stringstream userAgent;
|
|
|
|
|
2016-03-03 19:26:46 -03:00
|
|
|
// App name and version
|
2020-03-16 10:29:58 -03:00
|
|
|
userAgent << get_app_name() << "/" << get_app_version() << " (";
|
2011-07-26 23:25:02 -03:00
|
|
|
|
2021-11-02 14:18:14 -03:00
|
|
|
#if LAF_WINDOWS
|
2011-07-26 23:25:02 -03:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
// Windows
|
|
|
|
|
|
|
|
userAgent << "Windows";
|
2021-11-02 14:18:14 -03:00
|
|
|
switch (p.windowsType) {
|
|
|
|
case base::Platform::WindowsType::Server:
|
2011-07-26 23:25:02 -03:00
|
|
|
userAgent << " Server";
|
|
|
|
break;
|
2021-11-02 14:18:14 -03:00
|
|
|
case base::Platform::WindowsType::NT:
|
2011-07-26 23:25:02 -03:00
|
|
|
userAgent << " NT";
|
|
|
|
break;
|
|
|
|
}
|
2021-11-02 14:18:14 -03:00
|
|
|
userAgent << " " << p.osVer.major() << "." << p.osVer.minor();
|
2011-07-26 23:25:02 -03:00
|
|
|
|
2021-11-02 14:18:14 -03:00
|
|
|
if (p.servicePack.major() > 0)
|
|
|
|
userAgent << " SP" << p.servicePack.major();
|
2011-07-26 23:25:02 -03:00
|
|
|
|
2021-11-02 14:18:14 -03:00
|
|
|
if (p.isWow64)
|
2011-07-26 23:25:02 -03:00
|
|
|
userAgent << "; WOW64";
|
|
|
|
|
2021-11-02 14:18:14 -03:00
|
|
|
if (p.wineVer)
|
|
|
|
userAgent << "; Wine " << p.wineVer;
|
2019-06-06 12:15:31 -03:00
|
|
|
|
2021-11-02 14:18:14 -03:00
|
|
|
#elif LAF_MACOS
|
2011-07-26 23:25:02 -03:00
|
|
|
|
2021-11-02 14:18:14 -03:00
|
|
|
userAgent << "macOS "
|
|
|
|
<< p.osVer.major() << "."
|
|
|
|
<< p.osVer.minor() << "."
|
|
|
|
<< p.osVer.patch();
|
2011-07-26 23:25:02 -03:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
// Unix like
|
|
|
|
|
2021-11-02 14:18:14 -03:00
|
|
|
if (!p.distroName.empty()) {
|
|
|
|
userAgent << p.distroName;
|
|
|
|
if (!p.distroVer.empty())
|
|
|
|
userAgent << " " << p.distroVer;
|
2017-06-29 13:03:28 -03:00
|
|
|
}
|
2011-07-26 23:25:02 -03:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
userAgent << ")";
|
|
|
|
return userAgent.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace updater
|