Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 by Savoir-faire Linux |
| 3 | * Author: Yang Wang <yang.wang@savoirfairelinux.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #pragma once |
| 20 | |
| 21 | #include <QObject> |
| 22 | #include <QSettings> |
| 23 | |
| 24 | #include "api/account.h" |
| 25 | #include "api/datatransfermodel.h" |
| 26 | #include "lrcinstance.h" |
| 27 | #include "typedefs.h" |
| 28 | #include "utils.h" |
| 29 | |
| 30 | class SettingsAdaptor : public QObject |
| 31 | { |
| 32 | Q_OBJECT |
| 33 | public: |
| 34 | explicit SettingsAdaptor(QObject *parent = nullptr); |
| 35 | |
| 36 | //Singleton |
| 37 | static SettingsAdaptor &instance(); |
| 38 | /* |
| 39 | * getters of directories |
| 40 | */ |
| 41 | Q_INVOKABLE QString getDir_Document(); |
| 42 | Q_INVOKABLE QString getDir_Download(); |
| 43 | |
| 44 | /* |
| 45 | * getters and setters of app settings options |
| 46 | */ |
| 47 | Q_INVOKABLE bool getSettingsValue_CloseOrMinimized(); |
| 48 | Q_INVOKABLE bool getSettingsValue_EnableNotifications(); |
| 49 | Q_INVOKABLE bool getSettingsValue_AutoUpdate(); |
| 50 | |
| 51 | Q_INVOKABLE void setClosedOrMin(bool state); |
| 52 | Q_INVOKABLE void setNotifications(bool state); |
| 53 | Q_INVOKABLE void setUpdateAutomatic(bool state); |
| 54 | Q_INVOKABLE void setRunOnStartUp(bool state); |
| 55 | Q_INVOKABLE void setDownloadPath(QString dir); |
| 56 | |
| 57 | /* |
| 58 | * getters of devices' Info and options |
| 59 | */ |
| 60 | Q_INVOKABLE lrc::api::video::Capabilities get_DeviceCapabilities(const QString &device); |
| 61 | Q_INVOKABLE lrc::api::video::ResRateList get_ResRateList(lrc::api::video::Channel channel, |
| 62 | QString device); |
| 63 | Q_INVOKABLE int get_DeviceCapabilitiesSize(const QString &device); |
| 64 | |
| 65 | /* |
| 66 | * getters of resolution and frame rates of current device |
| 67 | */ |
| 68 | Q_INVOKABLE QVector<QString> getResolutions(const QString &device); |
| 69 | Q_INVOKABLE QVector<int> getFrameRates(const QString &device); |
| 70 | |
| 71 | /* |
| 72 | * getters and setters: lrc video::setting |
| 73 | */ |
| 74 | Q_INVOKABLE QString get_Video_Settings_Channel(const QString &deviceId); |
| 75 | Q_INVOKABLE QString get_Video_Settings_Name(const QString &deviceId); |
| 76 | Q_INVOKABLE QString get_Video_Settings_Id(const QString &deviceId); |
| 77 | Q_INVOKABLE qreal get_Video_Settings_Rate(const QString &deviceId); |
| 78 | Q_INVOKABLE QString get_Video_Settings_Size(const QString &deviceId); |
| 79 | |
| 80 | Q_INVOKABLE void set_Video_Settings_Rate_And_Resolution(const QString &deviceId, |
| 81 | qreal rate, |
| 82 | const QString &resolution); |
| 83 | |
| 84 | /* |
| 85 | * getters and setters of current account Info |
| 86 | */ |
| 87 | const Q_INVOKABLE lrc::api::account::Info &getCurrentAccountInfo(); |
| 88 | const Q_INVOKABLE lrc::api::profile::Info &getCurrentAccount_Profile_Info(); |
| 89 | |
| 90 | Q_INVOKABLE lrc::api::ContactModel *getContactModel(); |
| 91 | Q_INVOKABLE lrc::api::NewDeviceModel *getDeviceModel(); |
| 92 | |
| 93 | Q_INVOKABLE QString get_CurrentAccountInfo_RegisteredName(); |
| 94 | Q_INVOKABLE QString get_CurrentAccountInfo_Id(); |
| 95 | Q_INVOKABLE bool get_CurrentAccountInfo_Enabled(); |
| 96 | |
| 97 | // profile info |
| 98 | Q_INVOKABLE QString getCurrentAccount_Profile_Info_Uri(); |
| 99 | Q_INVOKABLE QString getCurrentAccount_Profile_Info_Alias(); |
| 100 | Q_INVOKABLE int getCurrentAccount_Profile_Info_Type(); |
| 101 | Q_INVOKABLE QString getAccountBestName(); |
| 102 | |
| 103 | // getters and setters of avatar image |
| 104 | Q_INVOKABLE QString getAvatarImage_Base64(int avatarSize); |
| 105 | Q_INVOKABLE bool getIsDefaultAvatar(); |
| 106 | Q_INVOKABLE bool setCurrAccAvatar(QString avatarImgBase64); |
| 107 | Q_INVOKABLE void clearCurrentAvatar(); |
| 108 | |
| 109 | /* |
| 110 | * getters and setters of ConfProperties_t |
| 111 | */ |
| 112 | // getters |
| 113 | Q_INVOKABLE lrc::api::account::ConfProperties_t getAccountConfig(); |
| 114 | Q_INVOKABLE QString getAccountConfig_Manageruri(); |
| 115 | Q_INVOKABLE QString getAccountConfig_Username(); |
| 116 | Q_INVOKABLE QString getAccountConfig_Hostname(); |
| 117 | Q_INVOKABLE QString getAccountConfig_Password(); |
| 118 | |
| 119 | Q_INVOKABLE QString getAccountConfig_ProxyServer(); |
| 120 | Q_INVOKABLE bool getAccountConfig_ProxyEnabled(); |
| 121 | |
| 122 | Q_INVOKABLE bool getAccountConfig_PeerDiscovery(); |
| 123 | Q_INVOKABLE bool getAccountConfig_DHT_PublicInCalls(); |
Sébastien Blin | cdcf43c | 2020-07-23 14:51:47 -0400 | [diff] [blame] | 124 | Q_INVOKABLE bool getAccountConfig_RendezVous(); |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 125 | Q_INVOKABLE bool getAccountConfig_AutoAnswer(); |
| 126 | |
| 127 | Q_INVOKABLE QString getAccountConfig_RingNS_Uri(); |
| 128 | |
| 129 | Q_INVOKABLE QString getAccountConfig_TLS_CertificateListFile(); |
| 130 | Q_INVOKABLE QString getAccountConfig_TLS_CertificateFile(); |
| 131 | Q_INVOKABLE QString getAccountConfig_TLS_PrivateKeyFile(); |
| 132 | Q_INVOKABLE bool getAccountConfig_TLS_Enable(); |
| 133 | Q_INVOKABLE QString getAccountConfig_TLS_Password(); |
| 134 | Q_INVOKABLE bool getAccountConfig_TLS_VerifyServer(); |
| 135 | Q_INVOKABLE bool getAccountConfig_TLS_VerifyClient(); |
| 136 | Q_INVOKABLE bool getAccountConfig_TLS_RequireClientCertificate(); |
| 137 | Q_INVOKABLE int getAccountConfig_TLS_Method_inInt(); |
| 138 | Q_INVOKABLE QString getAccountConfig_TLS_Servername(); |
| 139 | Q_INVOKABLE int getAccountConfig_TLS_NegotiationTimeoutSec(); |
| 140 | |
| 141 | Q_INVOKABLE bool getAccountConfig_SRTP_Enabled(); |
| 142 | Q_INVOKABLE int getAccountConfig_SRTP_KeyExchange(); |
| 143 | Q_INVOKABLE bool getAccountConfig_SRTP_RtpFallback(); |
| 144 | |
| 145 | Q_INVOKABLE bool getAccountConfig_UpnpEnabled(); |
| 146 | Q_INVOKABLE bool getAccountConfig_TURN_Enabled(); |
| 147 | Q_INVOKABLE QString getAccountConfig_TURN_Server(); |
| 148 | Q_INVOKABLE QString getAccountConfig_TURN_Username(); |
| 149 | Q_INVOKABLE QString getAccountConfig_TURN_Password(); |
| 150 | Q_INVOKABLE QString getAccountConfig_TURN_Realm(); |
| 151 | |
| 152 | Q_INVOKABLE bool getAccountConfig_STUN_Enabled(); |
| 153 | Q_INVOKABLE QString getAccountConfig_STUN_Server(); |
| 154 | |
| 155 | Q_INVOKABLE bool getAccountConfig_Video_Enabled(); |
| 156 | Q_INVOKABLE int getAccountConfig_Video_VideoPortMin(); |
| 157 | Q_INVOKABLE int getAccountConfig_Video_VideoPortMax(); |
| 158 | |
| 159 | Q_INVOKABLE int getAccountConfig_Audio_AudioPortMin(); |
| 160 | Q_INVOKABLE int getAccountConfig_Audio_AudioPortMax(); |
| 161 | |
| 162 | Q_INVOKABLE bool getAccountConfig_Ringtone_RingtoneEnabled(); |
| 163 | Q_INVOKABLE QString getAccountConfig_Ringtone_RingtonePath(); |
| 164 | |
| 165 | Q_INVOKABLE int getAccountConfig_Registration_Expire(); |
| 166 | Q_INVOKABLE int getAccountConfig_Localport(); |
| 167 | Q_INVOKABLE bool getAccountConfig_PublishedSameAsLocal(); |
| 168 | Q_INVOKABLE QString getAccountConfig_PublishedAddress(); |
| 169 | Q_INVOKABLE int getAccountConfig_PublishedPort(); |
| 170 | |
| 171 | Q_INVOKABLE QString getAccountConfig_Mailbox(); |
| 172 | |
| 173 | // setters |
| 174 | Q_INVOKABLE void setAccountConfig_Username(QString input); |
| 175 | Q_INVOKABLE void setAccountConfig_Hostname(QString input); |
| 176 | Q_INVOKABLE void setAccountConfig_Password(QString input); |
| 177 | Q_INVOKABLE void setAccountConfig_ProxyServer(QString input); |
| 178 | |
| 179 | Q_INVOKABLE void setAutoConnectOnLocalNetwork(bool state); |
| 180 | Q_INVOKABLE void setCallsUntrusted(bool state); |
Sébastien Blin | cdcf43c | 2020-07-23 14:51:47 -0400 | [diff] [blame] | 181 | Q_INVOKABLE void setIsRendezVous(bool state); |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 182 | Q_INVOKABLE void setAutoAnswerCalls(bool state); |
| 183 | Q_INVOKABLE void setEnableRingtone(bool state); |
| 184 | Q_INVOKABLE void setEnableProxy(bool state); |
| 185 | Q_INVOKABLE void setUseUPnP(bool state); |
| 186 | Q_INVOKABLE void setUseTURN(bool state); |
| 187 | Q_INVOKABLE void setUseSTUN(bool state); |
| 188 | Q_INVOKABLE void setVideoState(bool state); |
| 189 | Q_INVOKABLE void setUseSRTP(bool state); |
| 190 | Q_INVOKABLE void setUseSDES(bool state); |
| 191 | Q_INVOKABLE void setUseRTPFallback(bool state); |
| 192 | Q_INVOKABLE void setUseTLS(bool state); |
| 193 | Q_INVOKABLE void setVerifyCertificatesServer(bool state); |
| 194 | Q_INVOKABLE void setVerifyCertificatesClient(bool state); |
| 195 | Q_INVOKABLE void setRequireCertificatesIncomingTLS(bool state); |
| 196 | Q_INVOKABLE void setUseCustomAddressAndPort(bool state); |
| 197 | |
| 198 | Q_INVOKABLE void setNameServer(QString text); |
| 199 | Q_INVOKABLE void setProxyAddress(QString text); |
| 200 | Q_INVOKABLE void setBootstrapAddress(QString text); |
| 201 | Q_INVOKABLE void setTURNAddress(QString text); |
| 202 | Q_INVOKABLE void setTURNUsername(QString text); |
| 203 | Q_INVOKABLE void setTURNPassword(QString text); |
| 204 | Q_INVOKABLE void setTURNRealm(QString text); |
| 205 | Q_INVOKABLE void setSTUNAddress(QString text); |
| 206 | |
| 207 | Q_INVOKABLE void lineEditVoiceMailDialCodeEditFinished(QString text); |
| 208 | Q_INVOKABLE void outgoingTLSServerNameLineEditTextChanged(QString text); |
| 209 | Q_INVOKABLE void lineEditSIPCertPasswordLineEditTextChanged(QString text); |
| 210 | Q_INVOKABLE void lineEditSIPCustomAddressLineEditTextChanged(QString text); |
| 211 | |
| 212 | Q_INVOKABLE void customPortSIPSpinBoxValueChanged(int value); |
| 213 | Q_INVOKABLE void negotiationTimeoutSpinBoxValueChanged(int value); |
| 214 | Q_INVOKABLE void registrationTimeoutSpinBoxValueChanged(int value); |
| 215 | Q_INVOKABLE void networkInterfaceSpinBoxValueChanged(int value); |
| 216 | Q_INVOKABLE void audioRTPMinPortSpinBoxEditFinished(int value); |
| 217 | Q_INVOKABLE void audioRTPMaxPortSpinBoxEditFinished(int value); |
| 218 | Q_INVOKABLE void videoRTPMinPortSpinBoxEditFinished(int value); |
| 219 | Q_INVOKABLE void videoRTPMaxPortSpinBoxEditFinished(int value); |
| 220 | |
| 221 | Q_INVOKABLE void tlsProtocolComboBoxIndexChanged(const int &index); |
| 222 | |
| 223 | Q_INVOKABLE void setDeviceName(QString text); |
| 224 | |
| 225 | Q_INVOKABLE void unbanContact(int index); |
| 226 | |
| 227 | Q_INVOKABLE void audioCodecsStateChange(unsigned int id, bool isToEnable); |
| 228 | Q_INVOKABLE void videoCodecsStateChange(unsigned int id, bool isToEnable); |
| 229 | |
| 230 | Q_INVOKABLE void decreaseAudioCodecPriority(unsigned int id); |
| 231 | Q_INVOKABLE void increaseAudioCodecPriority(unsigned int id); |
| 232 | |
| 233 | Q_INVOKABLE void decreaseVideoCodecPriority(unsigned int id); |
| 234 | Q_INVOKABLE void increaseVideoCodecPriority(unsigned int id); |
| 235 | |
| 236 | Q_INVOKABLE void set_RingtonePath(QString text); |
| 237 | Q_INVOKABLE void set_FileCACert(QString text); |
| 238 | Q_INVOKABLE void set_FileUserCert(QString text); |
| 239 | Q_INVOKABLE void set_FilePrivateKey(QString text); |
| 240 | }; |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 241 | Q_DECLARE_METATYPE(SettingsAdaptor *) |