forked from mail-ru-im/im-desktop
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathurl_config.cpp
69 lines (57 loc) · 1.86 KB
/
url_config.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
#include "stdafx.h"
#include "url_config.h"
#include "utils/gui_coll_helper.h"
#include "utils/features.h"
#include "../common.shared/config/config.h"
namespace Ui
{
template<typename T>
static T toContainerOfString(const core::iarray* array)
{
T container;
if (array)
{
const auto size = array->size();
container.reserve(size);
for (int i = 0; i < size; ++i)
container.push_back(QString::fromUtf8(array->get_at(i)->get_as_string()));
}
return container;
}
void UrlConfig::updateUrls(const core::coll_helper& _coll)
{
filesParse_ = _coll.get<QString>("filesParse");
stickerShare_= _coll.get<QString>("stickerShare");
profile_ = _coll.get<QString>("profile");
mailAuth_ = _coll.get<QString>("mailAuth");
mailRedirect_ = _coll.get<QString>("mailRedirect");
mailWin_ = _coll.get<QString>("mailWin");
mailRead_ = _coll.get<QString>("mailRead");
const auto array = _coll.get_value_as_array("vcs_urls");
vcsUrls_ = toContainerOfString<QVector<QString>>(array);
if (vcsUrls_.empty())
{
const auto splittedUrls = Features::getVcsRoomList().split(ql1c(';'), QString::SkipEmptyParts);
QVector<QString> urls;
urls.reserve(splittedUrls.size());
for (const auto& url : splittedUrls)
urls.push_back(url);
vcsUrls_ = std::move(urls);
}
}
const QVector<QString>& UrlConfig::getVCSUrls() const
{
return vcsUrls_;
}
bool UrlConfig::isMailConfigPresent() const
{
if (!config::get().is_on(config::features::external_url_config))
return true;
return !mailAuth_.isEmpty();
}
UrlConfig& getUrlConfig()
{
static UrlConfig c;
return c;
}
}