-
Notifications
You must be signed in to change notification settings - Fork 10
/
info.cpp
74 lines (63 loc) · 1.93 KB
/
info.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
#include "info.hpp"
#include <QStandardPaths>
static const QString c_accountsDirectory = QLatin1String("telepathy/morse");
static const QString c_accountFile = QLatin1String("account.bin");
MorseInfo::MorseInfo(QObject *parent)
: QObject(parent)
{
connect(this, &MorseInfo::accountIdentifierChanged,
this, &MorseInfo::accountDataDirectoryChanged);
connect(this, &MorseInfo::serverIdentifierChanged,
this, &MorseInfo::accountDataDirectoryChanged);
}
quint32 MorseInfo::appId()
{
return 14617u;
}
QString MorseInfo::appHash()
{
return QStringLiteral("e17ac360fd072f83d5d08db45ce9a121");
}
QString MorseInfo::accountDataDirectory() const
{
if (m_accountIdentifier.isEmpty()) {
return QString();
}
const QString serverIdentifier = m_serverIdentifier.isEmpty() ? QStringLiteral("official") : m_serverIdentifier;
return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
+ QLatin1Char('/') + c_accountsDirectory
+ QLatin1Char('/') + serverIdentifier
+ QLatin1Char('/') + m_accountIdentifier;
}
QString MorseInfo::accountDataFilePath() const
{
const QString directory = accountDataDirectory();
if (directory.isEmpty()) {
return QString();
}
return directory + QLatin1Char('/') + c_accountFile;
}
QString MorseInfo::accountIdentifier() const
{
return m_accountIdentifier;
}
QString MorseInfo::serverIdentifier() const
{
return m_serverIdentifier;
}
void MorseInfo::setAccountIdentifier(const QString &newAccountIdentifier)
{
if (m_accountIdentifier == newAccountIdentifier) {
return;
}
m_accountIdentifier = newAccountIdentifier;
emit accountIdentifierChanged();
}
void MorseInfo::setServerIdentifier(const QString &newServerIdentifier)
{
if (m_serverIdentifier == newServerIdentifier) {
return;
}
m_serverIdentifier = newServerIdentifier;
emit serverIdentifierChanged();
}