Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
  • beta/202505231812
  • stable/20250523.0
  • nightly/20250523.0
  • nightly/20250515.0
  • nightly/20250510.0
  • nightly/20250509.1
  • nightly/20250509.0
  • stable/20250430.1
  • stable/20250430.0
  • beta/202504301614
  • nightly/20250430.0
  • stable/20250424.1
  • beta/202504241506
  • stable/20250424.0
  • nightly/20250424.1
  • nightly/20250424.0
  • nightly/20250422.0
  • beta/202504120241
  • stable/20250411.0
  • nightly/20250411.0
21 results

accountadapter.h

Blame
    • Andreas Traczyk's avatar
      ae058405
      qml interop: remove clientwrapper · ae058405
      Andreas Traczyk authored
      The clientwrapper class masks granular object registration within
      qml, and encourages code duplication between viewmodels(adapters)
      and code lasagnafication and the misuse of declarative Qml.
      
      Change-Id: I85fef214363e62e54fc0681282323ea4861000d6
      Gitlab: #66
      ae058405
      History
      qml interop: remove clientwrapper
      Andreas Traczyk authored
      The clientwrapper class masks granular object registration within
      qml, and encourages code duplication between viewmodels(adapters)
      and code lasagnafication and the misuse of declarative Qml.
      
      Change-Id: I85fef214363e62e54fc0681282323ea4861000d6
      Gitlab: #66
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    accountadapter.h 5.03 KiB
    /*
     * Copyright (C) 2020 by Savoir-faire Linux
     * Author: Mingrui Zhang   <mingrui.zhang@savoirfairelinux.com>
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation; either version 3 of the License, or
     * (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     */
    
    #pragma once
    
    #include "qmladapterbase.h"
    
    #include <QObject>
    #include <QSettings>
    #include <QString>
    
    #include "lrcinstance.h"
    #include "utils.h"
    
    class AccountAdapter final : public QmlAdapterBase
    {
        Q_OBJECT
    
        Q_PROPERTY(lrc::api::NewAccountModel* model READ getModel NOTIFY modelChanged)
    
        Q_PROPERTY(lrc::api::ContactModel* contactModel READ getContactModel NOTIFY contactModelChanged)
        Q_PROPERTY(lrc::api::NewDeviceModel* deviceModel READ getDeviceModel NOTIFY deviceModelChanged)
    
        Q_PROPERTY(QString currentAccountId MEMBER currentAccountId_ NOTIFY currentAccountIdChanged)
        Q_PROPERTY(lrc::api::profile::Type currentAccountType MEMBER currentAccountType_ NOTIFY
                       currentAccountTypeChanged)
        Q_PROPERTY(int accountListSize MEMBER accountListSize_ NOTIFY accountListSizeChanged)
    
    public:
        lrc::api::NewAccountModel* getModel();
        lrc::api::ContactModel* getContactModel();
        lrc::api::NewDeviceModel* getDeviceModel();
    
    signals:
        void modelChanged();
        void contactModelChanged();
        void deviceModelChanged();
    
        void currentAccountIdChanged();
        void currentAccountTypeChanged();
        void accountListSizeChanged();
    
    public:
        explicit AccountAdapter(QObject* parent = 0);
        ~AccountAdapter() = default;
    
    protected:
        void safeInit() override;
    
        /*
         * Change to account corresponding to combox box index.
         */
        Q_INVOKABLE void accountChanged(int index);
        /*
         * Create normal Jami account, SIP account and JAMS accounts.
         */
        Q_INVOKABLE void createJamiAccount(QString registeredName,
                                           const QVariantMap& settings,
                                           QString photoBoothImgBase64,
                                           bool isCreating);
        Q_INVOKABLE void createSIPAccount(const QVariantMap& settings, QString photoBoothImgBase64);
        Q_INVOKABLE void createJAMSAccount(const QVariantMap& settings);
        /*
         * Delete current account
         */
        Q_INVOKABLE void deleteCurrentAccount();
        /*
         * Setting related
         */
        Q_INVOKABLE void passwordSetStatusMessageBox(bool success, QString title, QString infoToDisplay);
        /*
         * conf property
         */
        Q_INVOKABLE bool hasPassword();
        Q_INVOKABLE void setArchiveHasPassword(bool isHavePassword);
        Q_INVOKABLE bool exportToFile(const QString& accountId,
                                      const QString& path,
                                      const QString& password = {}) const;
        Q_INVOKABLE void setArchivePasswordAsync(const QString& accountID, const QString& password);
        /*
         * lrc instances functions wrappers
         */
        Q_INVOKABLE bool savePassword(const QString& accountId,
                                      const QString& oldPassword,
                                      const QString& newPassword);
        Q_INVOKABLE void startAudioMeter(bool async);
        Q_INVOKABLE void stopAudioMeter(bool async);
        Q_INVOKABLE void startPreviewing(bool force = false, bool async = true);
        Q_INVOKABLE void stopPreviewing(bool async = true);
        Q_INVOKABLE bool hasVideoCall();
        Q_INVOKABLE bool isPreviewing();
        Q_INVOKABLE void setCurrAccDisplayName(const QString& text);
        Q_INVOKABLE void setSelectedAccountId(const QString& accountId = {});
        Q_INVOKABLE void setSelectedConvId(const QString& convId = {});
    
    signals:
        /*
         * Trigger other components to reconnect account related signals.
         */
        void accountStatusChanged();
        void updateConversationForAddedContact();
        /*
         * send report failure to QML to make it show the right UI state .
         */
        void reportFailure();
        void navigateToWelcomePageRequested();
        void accountAdded(bool showBackUp, int index);
    
    private:
        QString currentAccountId_;
        lrc::api::profile::Type currentAccountType_;
        int accountListSize_;
    
        void backToWelcomePage();
        void deselectConversation();
    
        /*
         * Make account signal connections.
         */
        void connectAccount(const QString& accountId);
        /*
         * Implement what to do when creat accout fails.
         */
        void connectFailure();
    
        QMetaObject::Connection accountStatusChangedConnection_;
        QMetaObject::Connection contactAddedConnection_;
        QMetaObject::Connection addedToConferenceConnection_;
        QMetaObject::Connection accountProfileChangedConnection_;
    };
    Q_DECLARE_METATYPE(AccountAdapter*)