Commit 30d8de51 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): account settings & settings in progress.

parent 3415e100
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "../components/contacts/ContactsListProxyModel.hpp" #include "../components/contacts/ContactsListProxyModel.hpp"
#include "../components/core/CoreManager.hpp" #include "../components/core/CoreManager.hpp"
#include "../components/settings/AccountSettingsModel.hpp" #include "../components/settings/AccountSettingsModel.hpp"
#include "../components/settings/SettingsModel.hpp"
#include "../components/timeline/TimelineModel.hpp" #include "../components/timeline/TimelineModel.hpp"
#include "../components/smart-search-bar/SmartSearchBarModel.hpp" #include "../components/smart-search-bar/SmartSearchBarModel.hpp"
...@@ -143,6 +144,13 @@ void App::registerTypes () { ...@@ -143,6 +144,13 @@ void App::registerTypes () {
} }
); );
qmlRegisterSingletonType<SettingsModel>(
"Linphone", 1, 0, "SettingsModel",
[](QQmlEngine *, QJSEngine *) -> QObject *{
return new SettingsModel();
}
);
qmlRegisterSingletonType<TimelineModel>( qmlRegisterSingletonType<TimelineModel>(
"Linphone", 1, 0, "TimelineModel", "Linphone", 1, 0, "TimelineModel",
[](QQmlEngine *, QJSEngine *) -> QObject *{ [](QQmlEngine *, QJSEngine *) -> QObject *{
......
#ifndef PRESENCE_H_ #ifndef PRESENCE_H_
#define PRESENCE_H_ #define PRESENCE_H_
#include <linphone++/linphone.hh>
#include <QObject> #include <QObject>
// ============================================================================= // =============================================================================
......
#include <QtDebug>
#include "../../utils.hpp"
#include "../core/CoreManager.hpp"
#include "AccountSettingsModel.hpp" #include "AccountSettingsModel.hpp"
// =================================================================== // =============================================================================
AccountSettingsModel::AccountSettingsModel (QObject *parent) : AccountSettingsModel::AccountSettingsModel (QObject *parent) : QObject(parent) {
QObject(parent) {} m_default_proxy = CoreManager::getInstance()->getCore()->getDefaultProxyConfig();
}
QString AccountSettingsModel::getUsername () const { QString AccountSettingsModel::getUsername () const {
return "Edward Miller "; shared_ptr<linphone::Address> address = getDefaultSipAddress();
const string &display_name = address->getDisplayName();
return ::Utils::linphoneStringToQString(
display_name.empty() ? address->getUsername() : display_name
);
} }
void AccountSettingsModel::setUsername (const QString &username) { void AccountSettingsModel::setUsername (const QString &username) {
// NOTHING TODO. shared_ptr<linphone::Address> address = getDefaultSipAddress();
(void) username;
if (address->setDisplayName(::Utils::qStringToLinphoneString(username)))
qWarning() << QStringLiteral("Unable to set displayName on sip address: `%1`.")
.arg(::Utils::linphoneStringToQString(address->asStringUriOnly()));
emit accountUpdated();
} }
Presence::PresenceLevel AccountSettingsModel::getPresenceLevel () const { Presence::PresenceLevel AccountSettingsModel::getPresenceLevel () const {
...@@ -23,22 +39,14 @@ Presence::PresenceStatus AccountSettingsModel::getPresenceStatus () const { ...@@ -23,22 +39,14 @@ Presence::PresenceStatus AccountSettingsModel::getPresenceStatus () const {
} }
QString AccountSettingsModel::getSipAddress () const { QString AccountSettingsModel::getSipAddress () const {
return QString("e.miller@sip-linphone.org"); return ::Utils::linphoneStringToQString(getDefaultSipAddress()->asStringUriOnly());
}
bool AccountSettingsModel::getAutoAnswerStatus () const {
return true;
} }
// TODO: TMP // -----------------------------------------------------------------------------
/*
shared_ptr<linphone::ProxyConfig> cfg = m_core->getDefaultProxyConfig();
shared_ptr<linphone::Address> address = cfg->getIdentityAddress();
shared_ptr<linphone::AuthInfo> auth_info = m_core->findAuthInfo("", address->getUsername(), cfg->getDomain());
if (auth_info) shared_ptr<linphone::Address> AccountSettingsModel::getDefaultSipAddress () const {
qDebug() << "OK"; if (m_default_proxy)
else return m_default_proxy->getIdentityAddress();
qDebug() << "FAIL";
*/ return CoreManager::getInstance()->getCore()->getPrimaryContactParsed();
}
...@@ -10,18 +10,8 @@ ...@@ -10,18 +10,8 @@
class AccountSettingsModel : public QObject { class AccountSettingsModel : public QObject {
Q_OBJECT; Q_OBJECT;
Q_PROPERTY( Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY accountUpdated);
QString username Q_PROPERTY(QString sipAddress READ getSipAddress NOTIFY accountUpdated);
READ getUsername
// WRITE setUsername
CONSTANT // TODO: TMP
);
Q_PROPERTY(
QString sipAddress
READ getSipAddress
CONSTANT
);
Q_PROPERTY( Q_PROPERTY(
Presence::PresenceLevel presenceLevel Presence::PresenceLevel presenceLevel
...@@ -35,15 +25,12 @@ class AccountSettingsModel : public QObject { ...@@ -35,15 +25,12 @@ class AccountSettingsModel : public QObject {
CONSTANT CONSTANT
); );
Q_PROPERTY(
bool autoAnswerStatus
READ getAutoAnswerStatus
CONSTANT
);
public: public:
AccountSettingsModel (QObject *parent = Q_NULLPTR); AccountSettingsModel (QObject *parent = Q_NULLPTR);
signals:
void accountUpdated ();
private: private:
QString getUsername () const; QString getUsername () const;
void setUsername (const QString &username); void setUsername (const QString &username);
...@@ -53,7 +40,9 @@ private: ...@@ -53,7 +40,9 @@ private:
QString getSipAddress () const; QString getSipAddress () const;
bool getAutoAnswerStatus () const; std::shared_ptr<linphone::Address> getDefaultSipAddress () const;
std::shared_ptr<linphone::ProxyConfig> m_default_proxy;
}; };
#endif // ACCOUNT_SETTINGS_MODEL_H_ #endif // ACCOUNT_SETTINGS_MODEL_H_
#include "../core/CoreManager.hpp"
#include "SettingsModel.hpp" #include "SettingsModel.hpp"
// =================================================================== using namespace std;
// =============================================================================
const string SettingsModel::UI_SECTION("ui");
SettingsModel::SettingsModel (QObject *parent) : QObject(parent) {
// TODO: Uncomment when `getConfig` will be available.
// m_config = CoreManager::getInstance()->getCore()->getConfig();
}
bool SettingsModel::getAutoAnswerStatus () const {
return true; // TODO: See above.
return !!m_config->getInt(UI_SECTION, "auto_answer", 0);
}
SettingsModel::SettingsModel (QObject *parent) : bool SettingsModel::setAutoAnswerStatus (bool status) {
QObject(parent) { m_config->setInt(UI_SECTION, "auto_answer", status);
emit autoAnswerStatusChanged(status);
} }
#ifndef SETTINGS_MODEL_H_ #ifndef SETTINGS_MODEL_H_
#define SETTINGS_MODEL_H_ #define SETTINGS_MODEL_H_
#include <linphone++/linphone.hh>
#include <QObject> #include <QObject>
#include "AccountSettingsModel.hpp" #include "AccountSettingsModel.hpp"
// =================================================================== // =============================================================================
class SettingsModel : public QObject { class SettingsModel : public QObject {
Q_OBJECT; Q_OBJECT;
Q_PROPERTY(bool autoAnswerStatus READ getAutoAnswerStatus WRITE setAutoAnswerStatus NOTIFY autoAnswerStatusChanged);
public: public:
SettingsModel (QObject *parent = Q_NULLPTR); SettingsModel (QObject *parent = Q_NULLPTR);
signals:
void autoAnswerStatusChanged (bool status);
private: private:
QList<AccountSettingsModel *> accountsSettings; bool getAutoAnswerStatus () const;
bool setAutoAnswerStatus (bool status);
std::shared_ptr<linphone::Config> m_config;
static const std::string UI_SECTION;
}; };
#endif // SETTINGS_MODEL_H_ #endif // SETTINGS_MODEL_H_
...@@ -11,6 +11,8 @@ Item { ...@@ -11,6 +11,8 @@ Item {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
property var account
signal clicked signal clicked
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -29,7 +31,7 @@ Item { ...@@ -29,7 +31,7 @@ Item {
Layout.preferredHeight: AccountStatusStyle.presenceLevel.size Layout.preferredHeight: AccountStatusStyle.presenceLevel.size
Layout.preferredWidth: AccountStatusStyle.presenceLevel.size Layout.preferredWidth: AccountStatusStyle.presenceLevel.size
icon: 'chevron' icon: 'chevron'
level: AccountSettingsModel.presenceLevel level: account.presenceLevel
} }
Text { Text {
...@@ -39,7 +41,7 @@ Item { ...@@ -39,7 +41,7 @@ Item {
elide: Text.ElideRight elide: Text.ElideRight
font.bold: true font.bold: true
font.pointSize: AccountStatusStyle.username.fontSize font.pointSize: AccountStatusStyle.username.fontSize
text: AccountSettingsModel.username text: account.username
verticalAlignment: Text.AlignBottom verticalAlignment: Text.AlignBottom
} }
} }
...@@ -49,7 +51,7 @@ Item { ...@@ -49,7 +51,7 @@ Item {
elide: Text.ElideRight elide: Text.ElideRight
font.pointSize: AccountStatusStyle.sipAddress.fontSize font.pointSize: AccountStatusStyle.sipAddress.fontSize
height: parent.height / 2 height: parent.height / 2
text: AccountSettingsModel.sipAddress text: account.sipAddress
verticalAlignment: Text.AlignTop verticalAlignment: Text.AlignTop
width: parent.width width: parent.width
} }
......
...@@ -113,6 +113,8 @@ ApplicationWindow { ...@@ -113,6 +113,8 @@ ApplicationWindow {
Layout.fillHeight: parent.height Layout.fillHeight: parent.height
Layout.preferredWidth: MainWindowStyle.accountStatus.width Layout.preferredWidth: MainWindowStyle.accountStatus.width
account: AccountSettingsModel
onClicked: Utils.openWindow('ManageAccounts', window) onClicked: Utils.openWindow('ManageAccounts', window)
} }
...@@ -120,7 +122,7 @@ ApplicationWindow { ...@@ -120,7 +122,7 @@ ApplicationWindow {
width: MainWindowStyle.autoAnswerStatus.width width: MainWindowStyle.autoAnswerStatus.width
Icon { Icon {
icon: AccountSettingsModel.autoAnswerStatus icon: SettingsModel.autoAnswerStatus
? 'auto_answer' ? 'auto_answer'
: '' : ''
iconSize: MainWindowStyle.autoAnswerStatus.iconSize iconSize: MainWindowStyle.autoAnswerStatus.iconSize
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment