File indexing completed on 2024-05-19 05:49:16
0001 /* 0002 SPDX-FileCopyrightText: 2007 Nicolas Ternisien <nicolas.ternisien@gmail.com> 0003 SPDX-FileCopyrightText: 2015 Vyacheslav Matyushin 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "journaldConfiguration.h" 0009 0010 JournaldConfiguration::JournaldConfiguration() 0011 { 0012 mDisplayCurrentBootOnly = true; 0013 mEntriesType = EntriesAll; 0014 0015 mConfiguration->setCurrentGroup(QLatin1String("JournaldLogMode")); 0016 mConfiguration->addItemBool(QLatin1String("CurrentBootOnly"), mDisplayCurrentBootOnly, true); 0017 mConfiguration->addItemInt(QLatin1String("EntriesType"), mEntriesType); 0018 mConfiguration->addItemStringList(QLatin1String("RemoteJournals"), mRemoteJournals); 0019 } 0020 0021 bool JournaldConfiguration::displayCurrentBootOnly() const 0022 { 0023 return mDisplayCurrentBootOnly; 0024 } 0025 0026 void JournaldConfiguration::setDisplayCurrentBootOnly(bool displayCurrentBootOnly) 0027 { 0028 mDisplayCurrentBootOnly = displayCurrentBootOnly; 0029 } 0030 0031 JournaldConfiguration::EntriesType JournaldConfiguration::entriesType() 0032 { 0033 if ((mEntriesType < EntriesAll) || (mEntriesType > EntriesSystem)) { 0034 mEntriesType = EntriesAll; 0035 } 0036 return static_cast<EntriesType>(mEntriesType); 0037 } 0038 0039 void JournaldConfiguration::setEntriesType(JournaldConfiguration::EntriesType entriesType) 0040 { 0041 mEntriesType = entriesType; 0042 } 0043 0044 QVector<JournalAddress> JournaldConfiguration::remoteJournals() const 0045 { 0046 QVector<JournalAddress> journals; 0047 for (const QString &addressItem : std::as_const(mRemoteJournals)) { 0048 JournalAddress addressInfo; 0049 addressInfo.address = addressItem.section(QChar::fromLatin1('|'), 0, 0); 0050 addressInfo.port = addressItem.section(QChar::fromLatin1('|'), 1, 1).toUInt(); 0051 const int https = addressItem.section(QChar::fromLatin1('|'), 2).toInt(); 0052 addressInfo.https = https != 0; 0053 journals.append(addressInfo); 0054 } 0055 return journals; 0056 } 0057 0058 void JournaldConfiguration::setRemoteJournals(const QVector<JournalAddress> &remoteJournals) 0059 { 0060 mRemoteJournals.clear(); 0061 for (const JournalAddress &addressInfo : remoteJournals) { 0062 mRemoteJournals.append(QStringLiteral("%1|%2|%3").arg(addressInfo.address).arg(addressInfo.port).arg(addressInfo.https ? 1 : 0)); 0063 } 0064 } 0065 0066 #include "moc_journaldConfiguration.cpp"