Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 by Savoir-faire Linux |
| 3 | * Author: Mingrui Zhang <mingrui.zhang@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 "qmladapterbase.h" |
| 22 | |
| 23 | #include <QObject> |
| 24 | #include <QSettings> |
| 25 | #include <QString> |
| 26 | |
| 27 | #include "lrcinstance.h" |
| 28 | #include "utils.h" |
| 29 | |
| 30 | class AccountAdapter : public QmlAdapterBase |
| 31 | { |
| 32 | Q_OBJECT |
| 33 | |
| 34 | public: |
| 35 | explicit AccountAdapter(QObject *parent = 0); |
| 36 | ~AccountAdapter(); |
| 37 | //Singleton |
| 38 | static AccountAdapter &instance(); |
| 39 | |
| 40 | /* |
| 41 | * Change to account corresponding to combox box index. |
| 42 | */ |
| 43 | Q_INVOKABLE void accountChanged(int index); |
| 44 | /* |
| 45 | * Create normal Jami account, SIP account and JAMS accounts. |
| 46 | */ |
| 47 | Q_INVOKABLE void createJamiAccount(QString registeredName, |
| 48 | const QVariantMap &settings, |
| 49 | QString photoBoothImgBase64, |
| 50 | bool isCreating); |
| 51 | Q_INVOKABLE void createSIPAccount(const QVariantMap &settings, QString photoBoothImgBase64); |
| 52 | Q_INVOKABLE void createJAMSAccount(const QVariantMap &settings); |
| 53 | /* |
| 54 | * Delete current account |
| 55 | */ |
| 56 | Q_INVOKABLE void deleteCurrentAccount(); |
| 57 | /* |
| 58 | * Setting related |
| 59 | */ |
| 60 | Q_INVOKABLE void settingsNeverShowAgain(bool checked); |
| 61 | Q_INVOKABLE void passwordSetStatusMessageBox(bool success, QString title, QString infoToDisplay); |
| 62 | /* |
| 63 | * conf property |
| 64 | */ |
| 65 | Q_INVOKABLE bool hasPassword(); |
| 66 | Q_INVOKABLE void setArchiveHasPassword(bool isHavePassword); |
| 67 | Q_INVOKABLE bool exportToFile(const QString &accountId, |
| 68 | const QString &path, |
| 69 | const QString &password = {}) const; |
| 70 | Q_INVOKABLE void setArchivePasswordAsync(const QString &accountID, const QString &password); |
| 71 | /* |
| 72 | * lrc instances functions wrappers |
| 73 | */ |
| 74 | Q_INVOKABLE bool savePassword(QString accountId, QString oldPassword, QString newPassword); |
| 75 | Q_INVOKABLE void startAudioMeter(bool async); |
| 76 | Q_INVOKABLE void stopAudioMeter(bool async); |
Yang Wang | c2ea0b1 | 2020-08-18 13:24:37 -0400 | [diff] [blame] | 77 | Q_INVOKABLE void startPreviewing(bool force = false, bool async = true); |
| 78 | Q_INVOKABLE void stopPreviewing(bool async = true); |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 79 | Q_INVOKABLE bool hasVideoCall(); |
| 80 | Q_INVOKABLE bool isPreviewing(); |
| 81 | Q_INVOKABLE void setCurrAccDisplayName(QString text); |
| 82 | Q_INVOKABLE void setSelectedAccountId(QString accountId = {}); |
| 83 | Q_INVOKABLE void setSelectedConvId(QString accountId = {}); |
| 84 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 85 | signals: |
| 86 | |
| 87 | /* |
| 88 | * Trigger other components to reconnect account related signals. |
| 89 | */ |
| 90 | void accountSignalsReconnect(const QString &accountId); |
| 91 | void accountStatusChanged(); |
| 92 | void updateConversationForAddedContact(); |
| 93 | /* |
| 94 | * send report failure to QML to make it show the right UI state . |
| 95 | */ |
| 96 | void reportFailure(); |
| 97 | void accountAdded(bool showBackUp, int index); |
| 98 | |
| 99 | private: |
| 100 | void initQmlObject() override final; |
ababi | 69f5dfc | 2020-08-25 15:07:57 +0200 | [diff] [blame] | 101 | void setSelectedAccount(const QString &accountId); |
| 102 | void backToWelcomePage(); |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 103 | void deselectConversation(); |
| 104 | |
| 105 | /* |
| 106 | * Make account signal connections. |
| 107 | */ |
| 108 | void connectAccount(const QString &accountId); |
| 109 | /* |
| 110 | * Implement what to do when creat accout fails. |
| 111 | */ |
| 112 | void connectFailure(); |
| 113 | |
| 114 | QMetaObject::Connection accountStatusChangedConnection_; |
| 115 | QMetaObject::Connection contactAddedConnection_; |
| 116 | QMetaObject::Connection addedToConferenceConnection_; |
Sébastien Blin | acb1cf0 | 2020-08-17 22:38:19 -0400 | [diff] [blame] | 117 | QMetaObject::Connection accountProfileChangedConnection_; |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 118 | }; |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 119 | Q_DECLARE_METATYPE(AccountAdapter *) |