forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_agent.cpp
77 lines (55 loc) · 1.54 KB
/
user_agent.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Aseprite
// Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "updater/user_agent.h"
#include "base/platform.h"
#include "ver/info.h"
#include <sstream>
#include <string>
namespace updater {
std::string getFullOSString()
{
base::Platform p = base::get_platform();
std::stringstream os;
#if LAF_WINDOWS
// ----------------------------------------------------------------------
// Windows
os << "Windows";
switch (p.windowsType) {
case base::Platform::WindowsType::Server: os << " Server"; break;
case base::Platform::WindowsType::NT: os << " NT"; break;
}
os << " " << p.osVer.str();
if (p.servicePack.major() > 0)
os << " SP" << p.servicePack.major();
if (p.isWow64)
os << "; WOW64";
if (p.wineVer)
os << "; Wine " << p.wineVer;
#elif LAF_MACOS
os << "macOS " << p.osVer.major() << "." << p.osVer.minor() << "." << p.osVer.patch();
#else
// ----------------------------------------------------------------------
// Unix like
if (!p.distroName.empty()) {
os << p.distroName;
if (!p.distroVer.empty())
os << " " << p.distroVer;
}
#endif
return os.str();
}
std::string getUserAgent()
{
std::stringstream userAgent;
// App name and version
userAgent << get_app_name() << "/" << get_app_version() << " (" << getFullOSString() << ")";
return userAgent.str();
}
} // namespace updater