File indexing completed on 2024-12-01 10:39:48

0001 /*
0002    SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "serverconfiginfo.h"
0008 #include "rocketchataccount.h"
0009 #include "ruqolaserverconfig.h"
0010 
0011 ServerConfigInfo::ServerConfigInfo(RocketChatAccount *account, QObject *parent)
0012     : QObject(parent)
0013     , mAccount(account)
0014 {
0015 }
0016 
0017 ServerConfigInfo::~ServerConfigInfo() = default;
0018 
0019 QString ServerConfigInfo::serverVersionStr() const
0020 {
0021     if (mAccount) {
0022         return mAccount->ruqolaServerConfig()->serverVersionStr();
0023     }
0024     return {};
0025 }
0026 
0027 QString ServerConfigInfo::accountName() const
0028 {
0029     if (mAccount) {
0030         return mAccount->settings()->accountName();
0031     }
0032     return {};
0033 }
0034 
0035 QString ServerConfigInfo::userName() const
0036 {
0037     if (mAccount) {
0038         return mAccount->settings()->userName();
0039     }
0040     return {};
0041 }
0042 
0043 QString ServerConfigInfo::serverUrl() const
0044 {
0045     if (mAccount) {
0046         return mAccount->settings()->serverUrl();
0047     }
0048     return {};
0049 }
0050 
0051 QString ServerConfigInfo::logoUrl() const
0052 {
0053     if (mAccount) {
0054         const QString logoUrl = mAccount->ruqolaServerConfig()->logoUrl().url;
0055         if (logoUrl.isEmpty()) {
0056             return {};
0057         }
0058         return mAccount->settings()->serverUrl() + QLatin1Char('/') + logoUrl;
0059     }
0060     return {};
0061 }
0062 
0063 QString ServerConfigInfo::faviconUrl() const
0064 {
0065     if (mAccount) {
0066         const QString faviconUrl = mAccount->ruqolaServerConfig()->faviconUrl().url;
0067         if (faviconUrl.isEmpty()) {
0068             return {};
0069         }
0070         return mAccount->settings()->serverUrl() + QLatin1Char('/') + faviconUrl;
0071     }
0072     return {};
0073 }
0074 
0075 #include "moc_serverconfiginfo.cpp"