Add Accounts.
This commit is contained in:
parent
17728d5c07
commit
f4e8ec0f26
23 changed files with 816 additions and 1376 deletions
|
|
@ -18,18 +18,23 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "tool/LinphoneEnums.hpp"
|
||||||
|
|
||||||
#include "App.hpp"
|
#include "App.hpp"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
|
|
||||||
|
#include "core/account/Account.hpp"
|
||||||
|
#include "core/account/AccountProxy.hpp"
|
||||||
#include "core/logger/QtLogger.hpp"
|
#include "core/logger/QtLogger.hpp"
|
||||||
#include "core/login/LoginPage.hpp"
|
#include "core/login/LoginPage.hpp"
|
||||||
#include "core/phone-number/PhoneNumber.hpp"
|
#include "core/phone-number/PhoneNumber.hpp"
|
||||||
#include "core/phone-number/PhoneNumberProxy.hpp"
|
#include "core/phone-number/PhoneNumberProxy.hpp"
|
||||||
#include "core/singleapplication/singleapplication.h"
|
#include "core/singleapplication/singleapplication.h"
|
||||||
#include "tool/Constants.hpp"
|
#include "tool/Constants.hpp"
|
||||||
|
|
||||||
#include "tool/providers/ImageProvider.hpp"
|
#include "tool/providers/ImageProvider.hpp"
|
||||||
|
|
||||||
App::App(int &argc, char *argv[])
|
App::App(int &argc, char *argv[])
|
||||||
|
|
@ -96,6 +101,10 @@ void App::initCppInterfaces() {
|
||||||
|
|
||||||
qmlRegisterType<PhoneNumberProxy>(Constants::MainQmlUri, 1, 0, "PhoneNumberProxy");
|
qmlRegisterType<PhoneNumberProxy>(Constants::MainQmlUri, 1, 0, "PhoneNumberProxy");
|
||||||
qmlRegisterUncreatableType<PhoneNumber>(Constants::MainQmlUri, 1, 0, "PhoneNumber", QLatin1String("Uncreatable"));
|
qmlRegisterUncreatableType<PhoneNumber>(Constants::MainQmlUri, 1, 0, "PhoneNumber", QLatin1String("Uncreatable"));
|
||||||
|
qmlRegisterType<AccountProxy>(Constants::MainQmlUri, 1, 0, "AccountProxy");
|
||||||
|
qmlRegisterUncreatableType<Account>(Constants::MainQmlUri, 1, 0, "Account", QLatin1String("Uncreatable"));
|
||||||
|
|
||||||
|
LinphoneEnums::registerMetaTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------
|
//------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
list(APPEND _LINPHONEAPP_SOURCES
|
list(APPEND _LINPHONEAPP_SOURCES
|
||||||
|
core/account/Account.cpp
|
||||||
|
core/account/AccountList.cpp
|
||||||
|
core/account/AccountProxy.cpp
|
||||||
core/App.cpp
|
core/App.cpp
|
||||||
core/logger/QtLogger.cpp
|
core/logger/QtLogger.cpp
|
||||||
core/login/LoginPage.cpp
|
core/login/LoginPage.cpp
|
||||||
|
|
|
||||||
78
Linphone/core/account/Account.cpp
Normal file
78
Linphone/core/account/Account.cpp
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010-2024 Belledonne Communications SARL.
|
||||||
|
*
|
||||||
|
* This file is part of linphone-desktop
|
||||||
|
* (see https://www.linphone.org).
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Account.hpp"
|
||||||
|
#include "tool/Utils.hpp"
|
||||||
|
|
||||||
|
Account::Account(const std::shared_ptr<linphone::Account> &account) : QObject(nullptr) {
|
||||||
|
// Should be call from model Thread
|
||||||
|
auto address = account->getContactAddress();
|
||||||
|
mContactAddress = address ? Utils::coreStringToAppString(account->getContactAddress()->asString()) : "";
|
||||||
|
auto params = account->getParams();
|
||||||
|
auto identityAddress = params->getIdentityAddress();
|
||||||
|
mIdentityAddress = identityAddress ? Utils::coreStringToAppString(identityAddress->asString()) : "";
|
||||||
|
mPictureUri = Utils::coreStringToAppString(params->getPictureUri());
|
||||||
|
mRegistrationState = LinphoneEnums::fromLinphone(account->getState());
|
||||||
|
|
||||||
|
mAccountModel = Utils::makeQObject_ptr<AccountModel>(account); // OK
|
||||||
|
connect(mAccountModel.get(), &AccountModel::registrationStateChanged, this, &Account::onRegistrationStateChanged);
|
||||||
|
connect(this, &Account::requestSetPictureUri, mAccountModel.get(), &AccountModel::setPictureUri,
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
connect(mAccountModel.get(), &AccountModel::pictureUriChanged, this, &Account::onPictureUriChanged,
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
|
||||||
|
Account::~Account() {
|
||||||
|
emit mAccountModel->removeListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Account::getContactAddress() const {
|
||||||
|
return mContactAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Account::getIdentityAddress() const {
|
||||||
|
return mIdentityAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Account::getPictureUri() const {
|
||||||
|
return mPictureUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
LinphoneEnums::RegistrationState Account::getRegistrationState() const {
|
||||||
|
return mRegistrationState;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Account::onRegistrationStateChanged(const std::shared_ptr<linphone::Account> &account,
|
||||||
|
linphone::RegistrationState state,
|
||||||
|
const std::string &message) {
|
||||||
|
mRegistrationState = LinphoneEnums::fromLinphone(state);
|
||||||
|
emit registrationStateChanged(Utils::coreStringToAppString(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Account::setPictureUri(const QString &uri) {
|
||||||
|
if (uri != mPictureUri) {
|
||||||
|
emit requestSetPictureUri(Utils::appStringToCoreString(uri));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Account::onPictureUriChanged(std::string uri) {
|
||||||
|
mPictureUri = Utils::coreStringToAppString(uri);
|
||||||
|
emit pictureUriChanged();
|
||||||
|
}
|
||||||
71
Linphone/core/account/Account.hpp
Normal file
71
Linphone/core/account/Account.hpp
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010-2024 Belledonne Communications SARL.
|
||||||
|
*
|
||||||
|
* This file is part of linphone-desktop
|
||||||
|
* (see https://www.linphone.org).
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ACCOUNT_H_
|
||||||
|
#define ACCOUNT_H_
|
||||||
|
|
||||||
|
#include "model/account/AccountModel.hpp"
|
||||||
|
#include "tool/LinphoneEnums.hpp"
|
||||||
|
#include <QObject>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include <linphone++/linphone.hh>
|
||||||
|
|
||||||
|
class Account : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(QString contactAddress READ getContactAddress CONSTANT)
|
||||||
|
Q_PROPERTY(QString identityAddress READ getIdentityAddress CONSTANT)
|
||||||
|
Q_PROPERTY(QString pictureUri READ getPictureUri WRITE setPictureUri NOTIFY pictureUriChanged)
|
||||||
|
Q_PROPERTY(
|
||||||
|
LinphoneEnums::RegistrationState registrationState READ getRegistrationState NOTIFY registrationStateChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Should be call from model Thread. Will be automatically in App thread after initialization
|
||||||
|
Account(const std::shared_ptr<linphone::Account> &account);
|
||||||
|
~Account();
|
||||||
|
|
||||||
|
QString getContactAddress() const;
|
||||||
|
QString getIdentityAddress() const;
|
||||||
|
QString getPictureUri() const;
|
||||||
|
LinphoneEnums::RegistrationState getRegistrationState() const;
|
||||||
|
|
||||||
|
void setPictureUri(const QString &uri);
|
||||||
|
|
||||||
|
void onPictureUriChanged(std::string uri);
|
||||||
|
void onRegistrationStateChanged(const std::shared_ptr<linphone::Account> &account,
|
||||||
|
linphone::RegistrationState state,
|
||||||
|
const std::string &message);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void pictureUriChanged();
|
||||||
|
void registrationStateChanged(const QString &message);
|
||||||
|
|
||||||
|
// Account requests
|
||||||
|
void requestSetPictureUri(std::string pictureUri);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString mContactAddress;
|
||||||
|
QString mIdentityAddress;
|
||||||
|
QString mPictureUri;
|
||||||
|
LinphoneEnums::RegistrationState mRegistrationState;
|
||||||
|
std::shared_ptr<AccountModel> mAccountModel;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
46
Linphone/core/account/AccountList.cpp
Normal file
46
Linphone/core/account/AccountList.cpp
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010-2024 Belledonne Communications SARL.
|
||||||
|
*
|
||||||
|
* This file is part of linphone-desktop
|
||||||
|
* (see https://www.linphone.org).
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "AccountList.hpp"
|
||||||
|
#include "Account.hpp"
|
||||||
|
#include "core/App.hpp"
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include <linphone++/linphone.hh>
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
|
||||||
|
AccountList::AccountList(QObject *parent) : ListProxy(parent) {
|
||||||
|
|
||||||
|
App::postModelAsync([=]() {
|
||||||
|
QList<QSharedPointer<Account>> accounts;
|
||||||
|
// Model thread.
|
||||||
|
auto linphoneAccounts = CoreModel::getInstance()->getCore()->getAccountList();
|
||||||
|
for (auto it : linphoneAccounts) {
|
||||||
|
auto model = QSharedPointer<Account>(new Account(it), &QObject::deleteLater);
|
||||||
|
model->moveToThread(this->thread());
|
||||||
|
accounts.push_back(model);
|
||||||
|
}
|
||||||
|
// Invoke for adding stuffs in caller thread
|
||||||
|
QMetaObject::invokeMethod(this, [this, accounts]() { add(accounts); });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountList::~AccountList() {
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010-2024 Belledonne Communications SARL.
|
* Copyright (c) 2010-2024 Belledonne Communications SARL.
|
||||||
*
|
*
|
||||||
* This file is part of linphone-desktop
|
* This file is part of linphone-desktop
|
||||||
|
|
@ -18,15 +18,18 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AccountListener.hpp"
|
#ifndef ACCOUNT_LIST_H_
|
||||||
|
#define ACCOUNT_LIST_H_
|
||||||
|
|
||||||
#include <QDebug>
|
#include "../proxy/ListProxy.hpp"
|
||||||
|
#include <QLocale>
|
||||||
|
// =============================================================================
|
||||||
|
|
||||||
AccountListener::AccountListener(QObject *parent) : QObject(parent) {
|
class AccountList : public ListProxy {
|
||||||
}
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
AccountList(QObject *parent = Q_NULLPTR);
|
||||||
|
~AccountList();
|
||||||
|
};
|
||||||
|
|
||||||
void AccountListener::onRegistrationStateChanged(const std::shared_ptr<linphone::Account> &account,
|
#endif
|
||||||
linphone::RegistrationState state,
|
|
||||||
const std::string &message) {
|
|
||||||
emit registrationStateChanged(account, state, message);
|
|
||||||
}
|
|
||||||
65
Linphone/core/account/AccountProxy.cpp
Normal file
65
Linphone/core/account/AccountProxy.cpp
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010-2024 Belledonne Communications SARL.
|
||||||
|
*
|
||||||
|
* This file is part of linphone-desktop
|
||||||
|
* (see https://www.linphone.org).
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "AccountProxy.hpp"
|
||||||
|
#include "Account.hpp"
|
||||||
|
#include "AccountList.hpp"
|
||||||
|
|
||||||
|
AccountProxy::AccountProxy(QObject *parent) : SortFilterProxy(parent) {
|
||||||
|
setSourceModel(new AccountList(this));
|
||||||
|
sort(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountProxy::~AccountProxy() {
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AccountProxy::getFilterText() const {
|
||||||
|
return mFilterText;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AccountProxy::setFilterText(const QString &filter) {
|
||||||
|
if (mFilterText != filter) {
|
||||||
|
mFilterText = filter;
|
||||||
|
invalidate();
|
||||||
|
emit filterTextChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AccountProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {
|
||||||
|
bool show = (mFilterText.isEmpty() || mFilterText == "*");
|
||||||
|
if (!show) {
|
||||||
|
QRegularExpression search(QRegularExpression::escape(mFilterText),
|
||||||
|
QRegularExpression::CaseInsensitiveOption |
|
||||||
|
QRegularExpression::UseUnicodePropertiesOption);
|
||||||
|
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||||
|
auto model = sourceModel()->data(index);
|
||||||
|
auto account = model.value<Account *>();
|
||||||
|
show = account->getIdentityAddress().contains(search);
|
||||||
|
}
|
||||||
|
|
||||||
|
return show;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AccountProxy::lessThan(const QModelIndex &left, const QModelIndex &right) const {
|
||||||
|
auto l = sourceModel()->data(left);
|
||||||
|
auto r = sourceModel()->data(right);
|
||||||
|
|
||||||
|
return l.value<Account *>()->getIdentityAddress() < r.value<Account *>()->getIdentityAddress();
|
||||||
|
}
|
||||||
50
Linphone/core/account/AccountProxy.hpp
Normal file
50
Linphone/core/account/AccountProxy.hpp
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010-2024 Belledonne Communications SARL.
|
||||||
|
*
|
||||||
|
* This file is part of linphone-desktop
|
||||||
|
* (see https://www.linphone.org).
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ACCOUNT_PROXY_H_
|
||||||
|
#define ACCOUNT_PROXY_H_
|
||||||
|
|
||||||
|
#include "../proxy/SortFilterProxy.hpp"
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
|
||||||
|
class AccountProxy : public SortFilterProxy {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(QString filterText READ getFilterText WRITE setFilterText NOTIFY filterTextChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
AccountProxy(QObject *parent = Q_NULLPTR);
|
||||||
|
~AccountProxy();
|
||||||
|
|
||||||
|
QString getFilterText() const;
|
||||||
|
void setFilterText(const QString &filter);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void filterTextChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||||
|
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
||||||
|
|
||||||
|
QString mFilterText;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,244 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2021 Belledonne Communications SARL.
|
|
||||||
*
|
|
||||||
* This file is part of linphone-desktop
|
|
||||||
* (see https://www.linphone.org).
|
|
||||||
*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef LINPHONE_ENUMS_H_
|
|
||||||
#define LINPHONE_ENUMS_H_
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <linphone++/linphone.hh>
|
|
||||||
|
|
||||||
// This namespace is used to pass Linphone enumerators to QML
|
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
namespace LinphoneEnums {
|
|
||||||
Q_NAMESPACE
|
|
||||||
|
|
||||||
void registerMetaTypes();
|
|
||||||
|
|
||||||
enum MediaEncryption {
|
|
||||||
MediaEncryptionNone = int(linphone::MediaEncryption::None),
|
|
||||||
MediaEncryptionDtls = int(linphone::MediaEncryption::DTLS),
|
|
||||||
MediaEncryptionSrtp = int(linphone::MediaEncryption::SRTP),
|
|
||||||
MediaEncryptionZrtp = int(linphone::MediaEncryption::ZRTP)
|
|
||||||
};
|
|
||||||
Q_ENUM_NS(MediaEncryption)
|
|
||||||
|
|
||||||
linphone::MediaEncryption toLinphone(const LinphoneEnums::MediaEncryption &encryption);
|
|
||||||
LinphoneEnums::MediaEncryption fromLinphone(const linphone::MediaEncryption &encryption);
|
|
||||||
|
|
||||||
enum FriendCapability {
|
|
||||||
FriendCapabilityNone = int(linphone::Friend::Capability::None),
|
|
||||||
FriendCapabilityGroupChat = int(linphone::Friend::Capability::GroupChat),
|
|
||||||
FriendCapabilityLimeX3Dh = int(linphone::Friend::Capability::LimeX3Dh),
|
|
||||||
FriendCapabilityEphemeralMessages = int(linphone::Friend::Capability::EphemeralMessages)
|
|
||||||
};
|
|
||||||
Q_ENUM_NS(FriendCapability)
|
|
||||||
|
|
||||||
linphone::Friend::Capability toLinphone(const LinphoneEnums::FriendCapability &capability);
|
|
||||||
LinphoneEnums::FriendCapability fromLinphone(const linphone::Friend::Capability &capability);
|
|
||||||
|
|
||||||
enum EventLogType {
|
|
||||||
EventLogTypeNone = int(linphone::EventLog::Type::None),
|
|
||||||
EventLogTypeConferenceCreated = int(linphone::EventLog::Type::ConferenceCreated),
|
|
||||||
EventLogTypeConferenceTerminated = int(linphone::EventLog::Type::ConferenceTerminated),
|
|
||||||
EventLogTypeConferenceCallStarted = int(linphone::EventLog::Type::ConferenceCallStarted),
|
|
||||||
EventLogTypeConferenceCallEnded = int(linphone::EventLog::Type::ConferenceCallEnded),
|
|
||||||
EventLogTypeConferenceChatMessage = int(linphone::EventLog::Type::ConferenceChatMessage),
|
|
||||||
EventLogTypeConferenceParticipantAdded = int(linphone::EventLog::Type::ConferenceParticipantAdded),
|
|
||||||
EventLogTypeConferenceParticipantRemoved = int(linphone::EventLog::Type::ConferenceParticipantRemoved),
|
|
||||||
EventLogTypeConferenceParticipantSetAdmin = int(linphone::EventLog::Type::ConferenceParticipantSetAdmin),
|
|
||||||
EventLogTypeConferenceParticipantUnsetAdmin = int(linphone::EventLog::Type::ConferenceParticipantUnsetAdmin),
|
|
||||||
EventLogTypeConferenceParticipantDeviceAdded = int(linphone::EventLog::Type::ConferenceParticipantDeviceAdded),
|
|
||||||
EventLogTypeConferenceParticipantDeviceRemoved = int(linphone::EventLog::Type::ConferenceParticipantDeviceRemoved),
|
|
||||||
EventLogTypeConferenceParticipantDeviceMediaAvailabilityChanged =
|
|
||||||
int(linphone::EventLog::Type::ConferenceParticipantDeviceMediaAvailabilityChanged),
|
|
||||||
EventLogTypeConferenceSubjectChanged = int(linphone::EventLog::Type::ConferenceSubjectChanged),
|
|
||||||
EventLogTypeConferenceAvailableMediaChanged = int(linphone::EventLog::Type::ConferenceAvailableMediaChanged),
|
|
||||||
EventLogTypeConferenceSecurityEvent = int(linphone::EventLog::Type::ConferenceSecurityEvent),
|
|
||||||
EventLogTypeConferenceEphemeralMessageLifetimeChanged =
|
|
||||||
int(linphone::EventLog::Type::ConferenceEphemeralMessageLifetimeChanged),
|
|
||||||
EventLogTypeConferenceEphemeralMessageEnabled = int(linphone::EventLog::Type::ConferenceEphemeralMessageEnabled),
|
|
||||||
EventLogTypeConferenceEphemeralMessageDisabled = int(linphone::EventLog::Type::ConferenceEphemeralMessageDisabled)
|
|
||||||
};
|
|
||||||
Q_ENUM_NS(EventLogType)
|
|
||||||
|
|
||||||
linphone::EventLog::Type toLinphone(const LinphoneEnums::EventLogType &capability);
|
|
||||||
LinphoneEnums::EventLogType fromLinphone(const linphone::EventLog::Type &data);
|
|
||||||
|
|
||||||
enum ChatMessageState {
|
|
||||||
ChatMessageStateIdle = int(linphone::ChatMessage::State::Idle),
|
|
||||||
ChatMessageStateInProgress = int(linphone::ChatMessage::State::InProgress),
|
|
||||||
ChatMessageStateDelivered = int(linphone::ChatMessage::State::Delivered),
|
|
||||||
ChatMessageStateNotDelivered = int(linphone::ChatMessage::State::NotDelivered),
|
|
||||||
ChatMessageStateFileTransferError = int(linphone::ChatMessage::State::FileTransferError),
|
|
||||||
ChatMessageStateFileTransferDone = int(linphone::ChatMessage::State::FileTransferDone),
|
|
||||||
ChatMessageStateDeliveredToUser = int(linphone::ChatMessage::State::DeliveredToUser),
|
|
||||||
ChatMessageStateDisplayed = int(linphone::ChatMessage::State::Displayed),
|
|
||||||
ChatMessageStateFileTransferInProgress = int(linphone::ChatMessage::State::FileTransferInProgress)
|
|
||||||
};
|
|
||||||
Q_ENUM_NS(ChatMessageState)
|
|
||||||
|
|
||||||
linphone::ChatMessage::State toLinphone(const LinphoneEnums::ChatMessageState &data);
|
|
||||||
LinphoneEnums::ChatMessageState fromLinphone(const linphone::ChatMessage::State &data);
|
|
||||||
|
|
||||||
enum ChatRoomState {
|
|
||||||
ChatRoomStateNone = int(linphone::ChatRoom::State::None),
|
|
||||||
ChatRoomStateInstantiated = int(linphone::ChatRoom::State::Instantiated),
|
|
||||||
ChatRoomStateCreationPending = int(linphone::ChatRoom::State::CreationPending),
|
|
||||||
ChatRoomStateCreated = int(linphone::ChatRoom::State::Created),
|
|
||||||
ChatRoomStateCreationFailed = int(linphone::ChatRoom::State::CreationFailed),
|
|
||||||
ChatRoomStateTerminationPending = int(linphone::ChatRoom::State::TerminationPending),
|
|
||||||
ChatRoomStateTerminated = int(linphone::ChatRoom::State::Terminated),
|
|
||||||
ChatRoomStateTerminationFailed = int(linphone::ChatRoom::State::TerminationFailed),
|
|
||||||
ChatRoomStateDeleted = int(linphone::ChatRoom::State::Deleted),
|
|
||||||
};
|
|
||||||
Q_ENUM_NS(ChatRoomState)
|
|
||||||
|
|
||||||
linphone::ChatRoom::State toLinphone(const LinphoneEnums::ChatRoomState &data);
|
|
||||||
LinphoneEnums::ChatRoomState fromLinphone(const linphone::ChatRoom::State &data);
|
|
||||||
|
|
||||||
enum CallStatus {
|
|
||||||
CallStatusDeclined = int(linphone::Call::Status::Declined),
|
|
||||||
CallStatusMissed = int(linphone::Call::Status::Missed),
|
|
||||||
CallStatusSuccess = int(linphone::Call::Status::Success),
|
|
||||||
CallStatusAborted = int(linphone::Call::Status::Aborted),
|
|
||||||
CallStatusEarlyAborted = int(linphone::Call::Status::EarlyAborted),
|
|
||||||
CallStatusAcceptedElsewhere = int(linphone::Call::Status::AcceptedElsewhere),
|
|
||||||
CallStatusDeclinedElsewhere = int(linphone::Call::Status::DeclinedElsewhere)
|
|
||||||
};
|
|
||||||
Q_ENUM_NS(CallStatus)
|
|
||||||
|
|
||||||
linphone::Call::Status toLinphone(const LinphoneEnums::CallStatus &capability);
|
|
||||||
LinphoneEnums::CallStatus fromLinphone(const linphone::Call::Status &capability);
|
|
||||||
|
|
||||||
enum ConferenceLayout {
|
|
||||||
ConferenceLayoutGrid = int(linphone::Conference::Layout::Grid),
|
|
||||||
ConferenceLayoutActiveSpeaker = int(linphone::Conference::Layout::ActiveSpeaker),
|
|
||||||
ConferenceLayoutAudioOnly = ConferenceLayoutGrid + ConferenceLayoutActiveSpeaker + 1,
|
|
||||||
};
|
|
||||||
Q_ENUM_NS(ConferenceLayout)
|
|
||||||
|
|
||||||
linphone::Conference::Layout toLinphone(const LinphoneEnums::ConferenceLayout &layout);
|
|
||||||
LinphoneEnums::ConferenceLayout fromLinphone(const linphone::Conference::Layout &layout);
|
|
||||||
|
|
||||||
enum ConferenceInfoState {
|
|
||||||
ConferenceInfoStateNew = int(linphone::ConferenceInfo::State::New),
|
|
||||||
ConferenceInfoStateUpdated = int(linphone::ConferenceInfo::State::Updated),
|
|
||||||
ConferenceInfoStateCancelled = int(linphone::ConferenceInfo::State::Cancelled)
|
|
||||||
};
|
|
||||||
Q_ENUM_NS(ConferenceInfoState)
|
|
||||||
|
|
||||||
linphone::ConferenceInfo::State toLinphone(const LinphoneEnums::ConferenceInfoState &state);
|
|
||||||
LinphoneEnums::ConferenceInfoState fromLinphone(const linphone::ConferenceInfo::State &state);
|
|
||||||
|
|
||||||
enum ConferenceSchedulerState {
|
|
||||||
ConferenceSchedulerStateAllocationPending = int(linphone::ConferenceScheduler::State::AllocationPending),
|
|
||||||
ConferenceSchedulerStateError = int(linphone::ConferenceScheduler::State::Error),
|
|
||||||
ConferenceSchedulerStateIdle = int(linphone::ConferenceScheduler::State::Idle),
|
|
||||||
ConferenceSchedulerStateReady = int(linphone::ConferenceScheduler::State::Ready),
|
|
||||||
ConferenceSchedulerStateUpdating = int(linphone::ConferenceScheduler::State::Updating)
|
|
||||||
};
|
|
||||||
Q_ENUM_NS(ConferenceSchedulerState)
|
|
||||||
|
|
||||||
linphone::ConferenceScheduler::State toLinphone(const LinphoneEnums::ConferenceSchedulerState &state);
|
|
||||||
LinphoneEnums::ConferenceSchedulerState fromLinphone(const linphone::ConferenceScheduler::State &state);
|
|
||||||
|
|
||||||
enum ParticipantDeviceState {
|
|
||||||
ParticipantDeviceStateJoining = int(linphone::ParticipantDevice::State::Joining),
|
|
||||||
ParticipantDeviceStatePresent = int(linphone::ParticipantDevice::State::Present),
|
|
||||||
ParticipantDeviceStateLeaving = int(linphone::ParticipantDevice::State::Leaving),
|
|
||||||
ParticipantDeviceStateLeft = int(linphone::ParticipantDevice::State::Left),
|
|
||||||
ParticipantDeviceStateScheduledForJoining = int(linphone::ParticipantDevice::State::ScheduledForJoining),
|
|
||||||
ParticipantDeviceStateScheduledForLeaving = int(linphone::ParticipantDevice::State::ScheduledForLeaving),
|
|
||||||
ParticipantDeviceStateOnHold = int(linphone::ParticipantDevice::State::OnHold),
|
|
||||||
ParticipantDeviceStateAlerting = int(linphone::ParticipantDevice::State::Alerting),
|
|
||||||
ParticipantDeviceStateMutedByFocus = int(linphone::ParticipantDevice::State::MutedByFocus),
|
|
||||||
|
|
||||||
};
|
|
||||||
Q_ENUM_NS(ParticipantDeviceState)
|
|
||||||
|
|
||||||
linphone::ParticipantDevice::State toLinphone(const LinphoneEnums::ParticipantDeviceState &state);
|
|
||||||
LinphoneEnums::ParticipantDeviceState fromLinphone(const linphone::ParticipantDevice::State &state);
|
|
||||||
|
|
||||||
enum TunnelMode {
|
|
||||||
TunnelModeDisable = int(linphone::Tunnel::Mode::Disable),
|
|
||||||
TunnelModeEnable = int(linphone::Tunnel::Mode::Enable),
|
|
||||||
TunnelModeAuto = int(linphone::Tunnel::Mode::Auto)
|
|
||||||
};
|
|
||||||
Q_ENUM_NS(TunnelMode)
|
|
||||||
|
|
||||||
linphone::Tunnel::Mode toLinphone(const LinphoneEnums::TunnelMode &mode);
|
|
||||||
LinphoneEnums::TunnelMode fromLinphone(const linphone::Tunnel::Mode &mode);
|
|
||||||
|
|
||||||
enum RecorderState {
|
|
||||||
RecorderStateClosed = int(linphone::Recorder::State::Closed),
|
|
||||||
RecorderStatePaused = int(linphone::Recorder::State::Paused),
|
|
||||||
RecorderStateRunning = int(linphone::Recorder::State::Running)
|
|
||||||
};
|
|
||||||
Q_ENUM_NS(RecorderState)
|
|
||||||
|
|
||||||
linphone::Recorder::State toLinphone(const LinphoneEnums::RecorderState &state);
|
|
||||||
LinphoneEnums::RecorderState fromLinphone(const linphone::Recorder::State &state);
|
|
||||||
|
|
||||||
enum TransportType {
|
|
||||||
TransportTypeDtls = int(linphone::TransportType::Dtls),
|
|
||||||
TransportTypeTcp = int(linphone::TransportType::Tcp),
|
|
||||||
TransportTypeTls = int(linphone::TransportType::Tls),
|
|
||||||
TransportTypeUdp = int(linphone::TransportType::Udp)
|
|
||||||
};
|
|
||||||
Q_ENUM_NS(TransportType)
|
|
||||||
|
|
||||||
linphone::TransportType toLinphone(const LinphoneEnums::TransportType &type);
|
|
||||||
LinphoneEnums::TransportType fromLinphone(const linphone::TransportType &type);
|
|
||||||
QString toString(const LinphoneEnums::TransportType &type);
|
|
||||||
void fromString(const QString &transportType, LinphoneEnums::TransportType *transport);
|
|
||||||
} // namespace LinphoneEnums
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(LinphoneEnums::CallStatus)
|
|
||||||
Q_DECLARE_METATYPE(LinphoneEnums::ChatMessageState)
|
|
||||||
Q_DECLARE_METATYPE(LinphoneEnums::ChatRoomState)
|
|
||||||
Q_DECLARE_METATYPE(LinphoneEnums::ConferenceLayout)
|
|
||||||
Q_DECLARE_METATYPE(LinphoneEnums::ConferenceInfoState)
|
|
||||||
Q_DECLARE_METATYPE(LinphoneEnums::ConferenceSchedulerState)
|
|
||||||
Q_DECLARE_METATYPE(LinphoneEnums::EventLogType)
|
|
||||||
Q_DECLARE_METATYPE(LinphoneEnums::FriendCapability)
|
|
||||||
Q_DECLARE_METATYPE(LinphoneEnums::MediaEncryption)
|
|
||||||
Q_DECLARE_METATYPE(LinphoneEnums::ParticipantDeviceState)
|
|
||||||
Q_DECLARE_METATYPE(LinphoneEnums::RecorderState)
|
|
||||||
Q_DECLARE_METATYPE(LinphoneEnums::TunnelMode)
|
|
||||||
Q_DECLARE_METATYPE(LinphoneEnums::TransportType)
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(std::shared_ptr<linphone::Call>)
|
|
||||||
Q_DECLARE_METATYPE(linphone::Call::State)
|
|
||||||
Q_DECLARE_METATYPE(std::shared_ptr<linphone::Core>)
|
|
||||||
Q_DECLARE_METATYPE(linphone::Config::ConfiguringState)
|
|
||||||
Q_DECLARE_METATYPE(std::string)
|
|
||||||
Q_DECLARE_METATYPE(linphone::GlobalState)
|
|
||||||
Q_DECLARE_METATYPE(std::shared_ptr<linphone::ChatRoom>)
|
|
||||||
Q_DECLARE_METATYPE(linphone::ChatRoom::State)
|
|
||||||
Q_DECLARE_METATYPE(linphone::RegistrationState)
|
|
||||||
Q_DECLARE_METATYPE(linphone::VersionUpdateCheckResult)
|
|
||||||
Q_DECLARE_METATYPE(std::shared_ptr<linphone::CallLog>)
|
|
||||||
Q_DECLARE_METATYPE(std::shared_ptr<const linphone::CallStats>)
|
|
||||||
Q_DECLARE_METATYPE(std::shared_ptr<linphone::EventLog>)
|
|
||||||
Q_DECLARE_METATYPE(std::shared_ptr<linphone::ChatMessage>)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
list(APPEND _LINPHONEAPP_SOURCES
|
list(APPEND _LINPHONEAPP_SOURCES
|
||||||
model/account/AccountListener.cpp
|
model/account/AccountModel.cpp
|
||||||
model/account/AccountManager.cpp
|
model/account/AccountManager.cpp
|
||||||
|
|
||||||
model/core/CoreModel.cpp
|
model/core/CoreModel.cpp
|
||||||
model/core/CoreListener.cpp
|
model/core/CoreListener.cpp
|
||||||
|
|
||||||
|
model/listener/Listener.hpp
|
||||||
|
|
||||||
model/logger/LoggerModel.cpp
|
model/logger/LoggerModel.cpp
|
||||||
model/logger/LoggerListener.cpp
|
model/logger/LoggerListener.cpp
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ bool AccountManager::login(QString username, QString password) {
|
||||||
auto params = account->getParams()->clone();
|
auto params = account->getParams()->clone();
|
||||||
// Sip address.
|
// Sip address.
|
||||||
auto identity = params->getIdentityAddress()->clone();
|
auto identity = params->getIdentityAddress()->clone();
|
||||||
if (mAccountListener) return false;
|
if (mAccountModel) return false;
|
||||||
|
|
||||||
identity->setUsername(Utils::appStringToCoreString(username));
|
identity->setUsername(Utils::appStringToCoreString(username));
|
||||||
if (params->setIdentityAddress(identity)) {
|
if (params->setIdentityAddress(identity)) {
|
||||||
|
|
@ -62,10 +62,8 @@ bool AccountManager::login(QString username, QString password) {
|
||||||
"", // Realm.
|
"", // Realm.
|
||||||
identity->getDomain() // Domain.
|
identity->getDomain() // Domain.
|
||||||
));
|
));
|
||||||
|
mAccountModel = Utils::makeQObject_ptr<AccountModel>(account);
|
||||||
mAccountListener = std::make_shared<AccountListener>(this);
|
connect(mAccountModel.get(), &AccountModel::registrationStateChanged, this,
|
||||||
account->addListener(mAccountListener);
|
|
||||||
connect(mAccountListener.get(), &AccountListener::registrationStateChanged, this,
|
|
||||||
&AccountManager::onRegistrationStateChanged);
|
&AccountManager::onRegistrationStateChanged);
|
||||||
core->addAccount(account);
|
core->addAccount(account);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -78,13 +76,13 @@ void AccountManager::onRegistrationStateChanged(const std::shared_ptr<linphone::
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case linphone::RegistrationState::Failed:
|
case linphone::RegistrationState::Failed:
|
||||||
core->removeAccount(account);
|
core->removeAccount(account);
|
||||||
account->removeListener(mAccountListener);
|
emit mAccountModel->removeListener();
|
||||||
mAccountListener = nullptr;
|
mAccountModel = nullptr;
|
||||||
emit logged(false);
|
emit logged(false);
|
||||||
break;
|
break;
|
||||||
case linphone::RegistrationState::Ok:
|
case linphone::RegistrationState::Ok:
|
||||||
account->removeListener(mAccountListener);
|
emit mAccountModel->removeListener();
|
||||||
mAccountListener = nullptr;
|
mAccountModel = nullptr;
|
||||||
emit logged(true);
|
emit logged(true);
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
|
|
|
||||||
|
|
@ -24,22 +24,25 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <linphone++/linphone.hh>
|
#include <linphone++/linphone.hh>
|
||||||
|
|
||||||
#include "AccountListener.hpp"
|
#include "AccountModel.hpp"
|
||||||
|
|
||||||
class AccountManager: public QObject {
|
class AccountManager : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AccountManager(QObject *parent = nullptr);
|
AccountManager(QObject *parent = nullptr);
|
||||||
|
|
||||||
bool login(QString username, QString password);
|
bool login(QString username, QString password);
|
||||||
|
|
||||||
std::shared_ptr<linphone::Account> createAccount(const QString& assistantFile);
|
std::shared_ptr<linphone::Account> createAccount(const QString &assistantFile);
|
||||||
|
|
||||||
void onRegistrationStateChanged(const std::shared_ptr<linphone::Account> & account, linphone::RegistrationState state, const std::string & message);
|
void onRegistrationStateChanged(const std::shared_ptr<linphone::Account> &account,
|
||||||
|
linphone::RegistrationState state,
|
||||||
|
const std::string &message);
|
||||||
signals:
|
signals:
|
||||||
void logged(bool isLoggued);
|
void logged(bool isLoggued);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<AccountListener> mAccountListener;
|
std::shared_ptr<AccountModel> mAccountModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
44
Linphone/model/account/AccountModel.cpp
Normal file
44
Linphone/model/account/AccountModel.cpp
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010-2024 Belledonne Communications SARL.
|
||||||
|
*
|
||||||
|
* This file is part of linphone-desktop
|
||||||
|
* (see https://www.linphone.org).
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "AccountModel.hpp"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
AccountModel::AccountModel(const std::shared_ptr<linphone::Account> &account, QObject *parent)
|
||||||
|
: ::Listener<linphone::Account, linphone::AccountListener>(account, parent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountModel::~AccountModel() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void AccountModel::onRegistrationStateChanged(const std::shared_ptr<linphone::Account> &account,
|
||||||
|
linphone::RegistrationState state,
|
||||||
|
const std::string &message) {
|
||||||
|
emit registrationStateChanged(account, state, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AccountModel::setPictureUri(std::string uri) {
|
||||||
|
auto account = std::dynamic_pointer_cast<linphone::Account>(mMonitor);
|
||||||
|
auto params = account->getParams()->clone();
|
||||||
|
params->setPictureUri(uri);
|
||||||
|
account->setParams(params);
|
||||||
|
emit pictureUriChanged(uri);
|
||||||
|
}
|
||||||
|
|
@ -18,23 +18,32 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ACCOUNT_LISTENER_H_
|
#ifndef ACCOUNT_MODEL_H_
|
||||||
#define ACCOUNT_LISTENER_H_
|
#define ACCOUNT_MODEL_H_
|
||||||
|
|
||||||
|
#include "model/listener/Listener.hpp"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <linphone++/linphone.hh>
|
#include <linphone++/linphone.hh>
|
||||||
|
|
||||||
class AccountListener : public QObject, public linphone::AccountListener {
|
class AccountModel : public ::Listener<linphone::Account, linphone::AccountListener>, public linphone::AccountListener {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AccountListener(QObject *parent = nullptr);
|
AccountModel(const std::shared_ptr<linphone::Account> &account, QObject *parent = nullptr);
|
||||||
|
~AccountModel();
|
||||||
|
|
||||||
virtual void onRegistrationStateChanged(const std::shared_ptr<linphone::Account> &account,
|
virtual void onRegistrationStateChanged(const std::shared_ptr<linphone::Account> &account,
|
||||||
linphone::RegistrationState state,
|
linphone::RegistrationState state,
|
||||||
const std::string &message) override;
|
const std::string &message) override;
|
||||||
|
|
||||||
|
void setPictureUri(std::string uri);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void registrationStateChanged(const std::shared_ptr<linphone::Account> & account, linphone::RegistrationState state, const std::string & message);
|
void registrationStateChanged(const std::shared_ptr<linphone::Account> &account,
|
||||||
|
linphone::RegistrationState state,
|
||||||
|
const std::string &message);
|
||||||
|
|
||||||
|
void pictureUriChanged(std::string uri);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
64
Linphone/model/listener/Listener.hpp
Normal file
64
Linphone/model/listener/Listener.hpp
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010-2024 Belledonne Communications SARL.
|
||||||
|
*
|
||||||
|
* This file is part of linphone-desktop
|
||||||
|
* (see https://www.linphone.org).
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LISTENER_H_
|
||||||
|
#define LISTENER_H_
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
class ListenerPrivate : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ListenerPrivate() {
|
||||||
|
connect(this, &ListenerPrivate::removeListener, this, &ListenerPrivate::onRemoveListener, Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
virtual void onRemoveListener() {
|
||||||
|
}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void removeListener();
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class LinphoneClass, class ListenerClass>
|
||||||
|
class Listener : public ListenerPrivate {
|
||||||
|
public:
|
||||||
|
Listener(std::shared_ptr<LinphoneClass> monitor, QObject *parent = nullptr) {
|
||||||
|
mMonitor = monitor;
|
||||||
|
}
|
||||||
|
~Listener() {
|
||||||
|
qDebug() << "Destroying Listener";
|
||||||
|
if (mMonitor && mSelf) mMonitor->removeListener(mSelf);
|
||||||
|
}
|
||||||
|
virtual void onRemoveListener() {
|
||||||
|
setSelf(nullptr);
|
||||||
|
}
|
||||||
|
void setSelf(const std::shared_ptr<ListenerClass> &self) {
|
||||||
|
if (mMonitor && mSelf) mMonitor->removeListener(mSelf);
|
||||||
|
mSelf = self;
|
||||||
|
if (self) mMonitor->addListener(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::shared_ptr<LinphoneClass> mMonitor;
|
||||||
|
std::shared_ptr<ListenerClass> mSelf;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
list(APPEND _LINPHONEAPP_SOURCES
|
list(APPEND _LINPHONEAPP_SOURCES
|
||||||
tool/Constants.cpp
|
tool/Constants.cpp
|
||||||
tool/Utils.cpp
|
tool/Utils.cpp
|
||||||
|
tool/LinphoneEnums.cpp
|
||||||
|
|
||||||
tool/providers/ImageProvider.cpp
|
tool/providers/ImageProvider.cpp
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,11 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
#include "LinphoneEnums.hpp"
|
#include "LinphoneEnums.hpp"
|
||||||
|
#include "Constants.hpp"
|
||||||
|
|
||||||
|
#include <QQmlEngine>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
|
|
@ -36,23 +38,11 @@ void LinphoneEnums::registerMetaTypes() {
|
||||||
qRegisterMetaType<LinphoneEnums::MediaEncryption>();
|
qRegisterMetaType<LinphoneEnums::MediaEncryption>();
|
||||||
qRegisterMetaType<LinphoneEnums::ParticipantDeviceState>();
|
qRegisterMetaType<LinphoneEnums::ParticipantDeviceState>();
|
||||||
qRegisterMetaType<LinphoneEnums::RecorderState>();
|
qRegisterMetaType<LinphoneEnums::RecorderState>();
|
||||||
|
qRegisterMetaType<LinphoneEnums::RegistrationState>();
|
||||||
qRegisterMetaType<LinphoneEnums::TunnelMode>();
|
qRegisterMetaType<LinphoneEnums::TunnelMode>();
|
||||||
qRegisterMetaType<LinphoneEnums::TransportType>();
|
qRegisterMetaType<LinphoneEnums::TransportType>();
|
||||||
|
qmlRegisterUncreatableMetaObject(LinphoneEnums::staticMetaObject, Constants::MainQmlUri, 1, 0, "LinphoneEnums",
|
||||||
qRegisterMetaType<std::shared_ptr<linphone::Call>>();
|
"Only enums");
|
||||||
qRegisterMetaType<linphone::Call::State>();
|
|
||||||
qRegisterMetaType<std::shared_ptr<linphone::Core>>();
|
|
||||||
qRegisterMetaType<linphone::Config::ConfiguringState>();
|
|
||||||
qRegisterMetaType<std::string>();
|
|
||||||
qRegisterMetaType<linphone::GlobalState>();
|
|
||||||
qRegisterMetaType<std::shared_ptr<linphone::ChatRoom>>();
|
|
||||||
qRegisterMetaType<linphone::ChatRoom::State>();
|
|
||||||
qRegisterMetaType<linphone::RegistrationState>();
|
|
||||||
qRegisterMetaType<linphone::VersionUpdateCheckResult>();
|
|
||||||
qRegisterMetaType<std::shared_ptr<linphone::CallLog>>();
|
|
||||||
qRegisterMetaType<std::shared_ptr<const linphone::CallStats>>();
|
|
||||||
qRegisterMetaType<std::shared_ptr<linphone::EventLog>>();
|
|
||||||
qRegisterMetaType<std::shared_ptr<linphone::ChatMessage>>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
linphone::MediaEncryption LinphoneEnums::toLinphone(const LinphoneEnums::MediaEncryption &data) {
|
linphone::MediaEncryption LinphoneEnums::toLinphone(const LinphoneEnums::MediaEncryption &data) {
|
||||||
|
|
@ -99,7 +89,7 @@ LinphoneEnums::CallStatus LinphoneEnums::fromLinphone(const linphone::Call::Stat
|
||||||
}
|
}
|
||||||
|
|
||||||
linphone::Conference::Layout LinphoneEnums::toLinphone(const LinphoneEnums::ConferenceLayout &layout) {
|
linphone::Conference::Layout LinphoneEnums::toLinphone(const LinphoneEnums::ConferenceLayout &layout) {
|
||||||
if (layout != LinphoneEnums::ConferenceLayoutAudioOnly) return static_cast<linphone::Conference::Layout>(layout);
|
if (layout != LinphoneEnums::ConferenceLayout::AudioOnly) return static_cast<linphone::Conference::Layout>(layout);
|
||||||
else return linphone::Conference::Layout::Grid; // Audio Only mode
|
else return linphone::Conference::Layout::Grid; // Audio Only mode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,6 +135,14 @@ LinphoneEnums::RecorderState LinphoneEnums::fromLinphone(const linphone::Recorde
|
||||||
return static_cast<LinphoneEnums::RecorderState>(data);
|
return static_cast<LinphoneEnums::RecorderState>(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
linphone::RegistrationState LinphoneEnums::toLinphone(const LinphoneEnums::RegistrationState &data) {
|
||||||
|
return static_cast<linphone::RegistrationState>(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
LinphoneEnums::RegistrationState LinphoneEnums::fromLinphone(const linphone::RegistrationState &data) {
|
||||||
|
return static_cast<LinphoneEnums::RegistrationState>(data);
|
||||||
|
}
|
||||||
|
|
||||||
linphone::TransportType LinphoneEnums::toLinphone(const LinphoneEnums::TransportType &type) {
|
linphone::TransportType LinphoneEnums::toLinphone(const LinphoneEnums::TransportType &type) {
|
||||||
return static_cast<linphone::TransportType>(type);
|
return static_cast<linphone::TransportType>(type);
|
||||||
}
|
}
|
||||||
|
|
@ -153,19 +151,19 @@ LinphoneEnums::TransportType LinphoneEnums::fromLinphone(const linphone::Transpo
|
||||||
}
|
}
|
||||||
QString LinphoneEnums::toString(const LinphoneEnums::TransportType &type) {
|
QString LinphoneEnums::toString(const LinphoneEnums::TransportType &type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TransportTypeTcp:
|
case TransportType::Tcp:
|
||||||
return "TCP";
|
return "TCP";
|
||||||
case TransportTypeUdp:
|
case TransportType::Udp:
|
||||||
return "UDP";
|
return "UDP";
|
||||||
case TransportTypeTls:
|
case TransportType::Tls:
|
||||||
return "TLS";
|
return "TLS";
|
||||||
case TransportTypeDtls:
|
case TransportType::Dtls:
|
||||||
return "DTLS";
|
return "DTLS";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void LinphoneEnums::fromString(const QString &transportType, LinphoneEnums::TransportType *transport) {
|
void LinphoneEnums::fromString(const QString &transportType, LinphoneEnums::TransportType *transport) {
|
||||||
if (transportType.toUpper() == QLatin1String("TCP")) *transport = TransportTypeTcp;
|
if (transportType.toUpper() == QLatin1String("TCP")) *transport = TransportType::Tcp;
|
||||||
else if (transportType.toUpper() == QLatin1String("UDP")) *transport = TransportTypeUdp;
|
else if (transportType.toUpper() == QLatin1String("UDP")) *transport = TransportType::Udp;
|
||||||
else if (transportType.toUpper() == QLatin1String("TLS")) *transport = TransportTypeTls;
|
else if (transportType.toUpper() == QLatin1String("TLS")) *transport = TransportType::Tls;
|
||||||
else *transport = TransportTypeDtls;
|
else *transport = TransportType::Dtls;
|
||||||
}
|
}
|
||||||
243
Linphone/tool/LinphoneEnums.hpp
Normal file
243
Linphone/tool/LinphoneEnums.hpp
Normal file
|
|
@ -0,0 +1,243 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 Belledonne Communications SARL.
|
||||||
|
*
|
||||||
|
* This file is part of linphone-desktop
|
||||||
|
* (see https://www.linphone.org).
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LINPHONE_ENUMS_H_
|
||||||
|
#define LINPHONE_ENUMS_H_
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <linphone++/linphone.hh>
|
||||||
|
|
||||||
|
// This namespace is used to pass Linphone enumerators to QML
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
|
||||||
|
namespace LinphoneEnums {
|
||||||
|
Q_NAMESPACE
|
||||||
|
|
||||||
|
void registerMetaTypes();
|
||||||
|
|
||||||
|
enum class MediaEncryption {
|
||||||
|
None = int(linphone::MediaEncryption::None),
|
||||||
|
Dtls = int(linphone::MediaEncryption::DTLS),
|
||||||
|
Srtp = int(linphone::MediaEncryption::SRTP),
|
||||||
|
Zrtp = int(linphone::MediaEncryption::ZRTP)
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(MediaEncryption)
|
||||||
|
|
||||||
|
linphone::MediaEncryption toLinphone(const LinphoneEnums::MediaEncryption &encryption);
|
||||||
|
LinphoneEnums::MediaEncryption fromLinphone(const linphone::MediaEncryption &encryption);
|
||||||
|
|
||||||
|
enum class FriendCapability {
|
||||||
|
None = int(linphone::Friend::Capability::None),
|
||||||
|
GroupChat = int(linphone::Friend::Capability::GroupChat),
|
||||||
|
LimeX3Dh = int(linphone::Friend::Capability::LimeX3Dh),
|
||||||
|
EphemeralMessages = int(linphone::Friend::Capability::EphemeralMessages)
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(FriendCapability)
|
||||||
|
|
||||||
|
linphone::Friend::Capability toLinphone(const LinphoneEnums::FriendCapability &capability);
|
||||||
|
LinphoneEnums::FriendCapability fromLinphone(const linphone::Friend::Capability &capability);
|
||||||
|
|
||||||
|
enum class EventLogType {
|
||||||
|
None = int(linphone::EventLog::Type::None),
|
||||||
|
ConferenceCreated = int(linphone::EventLog::Type::ConferenceCreated),
|
||||||
|
ConferenceTerminated = int(linphone::EventLog::Type::ConferenceTerminated),
|
||||||
|
ConferenceCallStarted = int(linphone::EventLog::Type::ConferenceCallStarted),
|
||||||
|
ConferenceCallEnded = int(linphone::EventLog::Type::ConferenceCallEnded),
|
||||||
|
ConferenceChatMessage = int(linphone::EventLog::Type::ConferenceChatMessage),
|
||||||
|
ConferenceParticipantAdded = int(linphone::EventLog::Type::ConferenceParticipantAdded),
|
||||||
|
ConferenceParticipantRemoved = int(linphone::EventLog::Type::ConferenceParticipantRemoved),
|
||||||
|
ConferenceParticipantSetAdmin = int(linphone::EventLog::Type::ConferenceParticipantSetAdmin),
|
||||||
|
ConferenceParticipantUnsetAdmin = int(linphone::EventLog::Type::ConferenceParticipantUnsetAdmin),
|
||||||
|
ConferenceParticipantDeviceAdded = int(linphone::EventLog::Type::ConferenceParticipantDeviceAdded),
|
||||||
|
ConferenceParticipantDeviceRemoved = int(linphone::EventLog::Type::ConferenceParticipantDeviceRemoved),
|
||||||
|
ConferenceParticipantDeviceMediaAvailabilityChanged =
|
||||||
|
int(linphone::EventLog::Type::ConferenceParticipantDeviceMediaAvailabilityChanged),
|
||||||
|
ConferenceSubjectChanged = int(linphone::EventLog::Type::ConferenceSubjectChanged),
|
||||||
|
ConferenceAvailableMediaChanged = int(linphone::EventLog::Type::ConferenceAvailableMediaChanged),
|
||||||
|
ConferenceSecurityEvent = int(linphone::EventLog::Type::ConferenceSecurityEvent),
|
||||||
|
ConferenceEphemeralMessageLifetimeChanged =
|
||||||
|
int(linphone::EventLog::Type::ConferenceEphemeralMessageLifetimeChanged),
|
||||||
|
ConferenceEphemeralMessageEnabled = int(linphone::EventLog::Type::ConferenceEphemeralMessageEnabled),
|
||||||
|
ConferenceEphemeralMessageDisabled = int(linphone::EventLog::Type::ConferenceEphemeralMessageDisabled)
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(EventLogType)
|
||||||
|
|
||||||
|
linphone::EventLog::Type toLinphone(const LinphoneEnums::EventLogType &capability);
|
||||||
|
LinphoneEnums::EventLogType fromLinphone(const linphone::EventLog::Type &data);
|
||||||
|
|
||||||
|
enum class ChatMessageState {
|
||||||
|
StateIdle = int(linphone::ChatMessage::State::Idle),
|
||||||
|
StateInProgress = int(linphone::ChatMessage::State::InProgress),
|
||||||
|
StateDelivered = int(linphone::ChatMessage::State::Delivered),
|
||||||
|
StateNotDelivered = int(linphone::ChatMessage::State::NotDelivered),
|
||||||
|
StateFileTransferError = int(linphone::ChatMessage::State::FileTransferError),
|
||||||
|
StateFileTransferDone = int(linphone::ChatMessage::State::FileTransferDone),
|
||||||
|
StateDeliveredToUser = int(linphone::ChatMessage::State::DeliveredToUser),
|
||||||
|
StateDisplayed = int(linphone::ChatMessage::State::Displayed),
|
||||||
|
StateFileTransferInProgress = int(linphone::ChatMessage::State::FileTransferInProgress)
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(ChatMessageState)
|
||||||
|
|
||||||
|
linphone::ChatMessage::State toLinphone(const LinphoneEnums::ChatMessageState &data);
|
||||||
|
LinphoneEnums::ChatMessageState fromLinphone(const linphone::ChatMessage::State &data);
|
||||||
|
|
||||||
|
enum class ChatRoomState {
|
||||||
|
None = int(linphone::ChatRoom::State::None),
|
||||||
|
Instantiated = int(linphone::ChatRoom::State::Instantiated),
|
||||||
|
CreationPending = int(linphone::ChatRoom::State::CreationPending),
|
||||||
|
Created = int(linphone::ChatRoom::State::Created),
|
||||||
|
CreationFailed = int(linphone::ChatRoom::State::CreationFailed),
|
||||||
|
TerminationPending = int(linphone::ChatRoom::State::TerminationPending),
|
||||||
|
Terminated = int(linphone::ChatRoom::State::Terminated),
|
||||||
|
TerminationFailed = int(linphone::ChatRoom::State::TerminationFailed),
|
||||||
|
Deleted = int(linphone::ChatRoom::State::Deleted),
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(ChatRoomState)
|
||||||
|
|
||||||
|
linphone::ChatRoom::State toLinphone(const LinphoneEnums::ChatRoomState &data);
|
||||||
|
LinphoneEnums::ChatRoomState fromLinphone(const linphone::ChatRoom::State &data);
|
||||||
|
|
||||||
|
enum class CallStatus {
|
||||||
|
Declined = int(linphone::Call::Status::Declined),
|
||||||
|
Missed = int(linphone::Call::Status::Missed),
|
||||||
|
Success = int(linphone::Call::Status::Success),
|
||||||
|
Aborted = int(linphone::Call::Status::Aborted),
|
||||||
|
EarlyAborted = int(linphone::Call::Status::EarlyAborted),
|
||||||
|
AcceptedElsewhere = int(linphone::Call::Status::AcceptedElsewhere),
|
||||||
|
DeclinedElsewhere = int(linphone::Call::Status::DeclinedElsewhere)
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(CallStatus)
|
||||||
|
|
||||||
|
linphone::Call::Status toLinphone(const LinphoneEnums::CallStatus &capability);
|
||||||
|
LinphoneEnums::CallStatus fromLinphone(const linphone::Call::Status &capability);
|
||||||
|
|
||||||
|
enum class ConferenceLayout {
|
||||||
|
Grid = int(linphone::Conference::Layout::Grid),
|
||||||
|
ActiveSpeaker = int(linphone::Conference::Layout::ActiveSpeaker),
|
||||||
|
AudioOnly = Grid + ActiveSpeaker + 1,
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(ConferenceLayout)
|
||||||
|
|
||||||
|
linphone::Conference::Layout toLinphone(const LinphoneEnums::ConferenceLayout &layout);
|
||||||
|
LinphoneEnums::ConferenceLayout fromLinphone(const linphone::Conference::Layout &layout);
|
||||||
|
|
||||||
|
enum ConferenceInfoState {
|
||||||
|
ConferenceInfoStateNew = int(linphone::ConferenceInfo::State::New),
|
||||||
|
ConferenceInfoStateUpdated = int(linphone::ConferenceInfo::State::Updated),
|
||||||
|
ConferenceInfoStateCancelled = int(linphone::ConferenceInfo::State::Cancelled)
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(ConferenceInfoState)
|
||||||
|
|
||||||
|
linphone::ConferenceInfo::State toLinphone(const LinphoneEnums::ConferenceInfoState &state);
|
||||||
|
LinphoneEnums::ConferenceInfoState fromLinphone(const linphone::ConferenceInfo::State &state);
|
||||||
|
|
||||||
|
enum class ConferenceSchedulerState {
|
||||||
|
AllocationPending = int(linphone::ConferenceScheduler::State::AllocationPending),
|
||||||
|
Error = int(linphone::ConferenceScheduler::State::Error),
|
||||||
|
Idle = int(linphone::ConferenceScheduler::State::Idle),
|
||||||
|
Ready = int(linphone::ConferenceScheduler::State::Ready),
|
||||||
|
Updating = int(linphone::ConferenceScheduler::State::Updating)
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(ConferenceSchedulerState)
|
||||||
|
|
||||||
|
linphone::ConferenceScheduler::State toLinphone(const LinphoneEnums::ConferenceSchedulerState &state);
|
||||||
|
LinphoneEnums::ConferenceSchedulerState fromLinphone(const linphone::ConferenceScheduler::State &state);
|
||||||
|
|
||||||
|
enum class ParticipantDeviceState {
|
||||||
|
Joining = int(linphone::ParticipantDevice::State::Joining),
|
||||||
|
Present = int(linphone::ParticipantDevice::State::Present),
|
||||||
|
Leaving = int(linphone::ParticipantDevice::State::Leaving),
|
||||||
|
Left = int(linphone::ParticipantDevice::State::Left),
|
||||||
|
ScheduledForJoining = int(linphone::ParticipantDevice::State::ScheduledForJoining),
|
||||||
|
ScheduledForLeaving = int(linphone::ParticipantDevice::State::ScheduledForLeaving),
|
||||||
|
OnHold = int(linphone::ParticipantDevice::State::OnHold),
|
||||||
|
Alerting = int(linphone::ParticipantDevice::State::Alerting),
|
||||||
|
MutedByFocus = int(linphone::ParticipantDevice::State::MutedByFocus),
|
||||||
|
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(ParticipantDeviceState)
|
||||||
|
|
||||||
|
linphone::ParticipantDevice::State toLinphone(const LinphoneEnums::ParticipantDeviceState &state);
|
||||||
|
LinphoneEnums::ParticipantDeviceState fromLinphone(const linphone::ParticipantDevice::State &state);
|
||||||
|
|
||||||
|
enum class RegistrationState {
|
||||||
|
None = int(linphone::RegistrationState::None),
|
||||||
|
Progress = int(linphone::RegistrationState::Progress),
|
||||||
|
Ok = int(linphone::RegistrationState::Ok),
|
||||||
|
Cleared = int(linphone::RegistrationState::Cleared),
|
||||||
|
Failed = int(linphone::RegistrationState::Failed),
|
||||||
|
Refreshing = int(linphone::RegistrationState::Refreshing)
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(RegistrationState)
|
||||||
|
|
||||||
|
linphone::RegistrationState toLinphone(const LinphoneEnums::RegistrationState &data);
|
||||||
|
LinphoneEnums::RegistrationState fromLinphone(const linphone::RegistrationState &data);
|
||||||
|
|
||||||
|
enum class TunnelMode {
|
||||||
|
Disable = int(linphone::Tunnel::Mode::Disable),
|
||||||
|
Enable = int(linphone::Tunnel::Mode::Enable),
|
||||||
|
Auto = int(linphone::Tunnel::Mode::Auto)
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(TunnelMode)
|
||||||
|
|
||||||
|
linphone::Tunnel::Mode toLinphone(const LinphoneEnums::TunnelMode &mode);
|
||||||
|
LinphoneEnums::TunnelMode fromLinphone(const linphone::Tunnel::Mode &mode);
|
||||||
|
|
||||||
|
enum class RecorderState {
|
||||||
|
Closed = int(linphone::Recorder::State::Closed),
|
||||||
|
Paused = int(linphone::Recorder::State::Paused),
|
||||||
|
Running = int(linphone::Recorder::State::Running)
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(RecorderState)
|
||||||
|
|
||||||
|
linphone::Recorder::State toLinphone(const LinphoneEnums::RecorderState &state);
|
||||||
|
LinphoneEnums::RecorderState fromLinphone(const linphone::Recorder::State &state);
|
||||||
|
|
||||||
|
enum class TransportType {
|
||||||
|
Dtls = int(linphone::TransportType::Dtls),
|
||||||
|
Tcp = int(linphone::TransportType::Tcp),
|
||||||
|
Tls = int(linphone::TransportType::Tls),
|
||||||
|
Udp = int(linphone::TransportType::Udp)
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(TransportType)
|
||||||
|
|
||||||
|
linphone::TransportType toLinphone(const LinphoneEnums::TransportType &type);
|
||||||
|
LinphoneEnums::TransportType fromLinphone(const linphone::TransportType &type);
|
||||||
|
QString toString(const LinphoneEnums::TransportType &type);
|
||||||
|
void fromString(const QString &transportType, LinphoneEnums::TransportType *transport);
|
||||||
|
} // namespace LinphoneEnums
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(LinphoneEnums::CallStatus)
|
||||||
|
Q_DECLARE_METATYPE(LinphoneEnums::ChatMessageState)
|
||||||
|
Q_DECLARE_METATYPE(LinphoneEnums::ChatRoomState)
|
||||||
|
Q_DECLARE_METATYPE(LinphoneEnums::ConferenceLayout)
|
||||||
|
Q_DECLARE_METATYPE(LinphoneEnums::ConferenceInfoState)
|
||||||
|
Q_DECLARE_METATYPE(LinphoneEnums::ConferenceSchedulerState)
|
||||||
|
Q_DECLARE_METATYPE(LinphoneEnums::EventLogType)
|
||||||
|
Q_DECLARE_METATYPE(LinphoneEnums::FriendCapability)
|
||||||
|
Q_DECLARE_METATYPE(LinphoneEnums::MediaEncryption)
|
||||||
|
Q_DECLARE_METATYPE(LinphoneEnums::ParticipantDeviceState)
|
||||||
|
Q_DECLARE_METATYPE(LinphoneEnums::RecorderState)
|
||||||
|
Q_DECLARE_METATYPE(LinphoneEnums::RegistrationState)
|
||||||
|
Q_DECLARE_METATYPE(LinphoneEnums::TunnelMode)
|
||||||
|
Q_DECLARE_METATYPE(LinphoneEnums::TransportType)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -18,35 +18,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QAction>
|
|
||||||
#include <QBitmap>
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QCryptographicHash>
|
|
||||||
#include <QCursor>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QImageReader>
|
|
||||||
#include <QMimeDatabase>
|
|
||||||
#include <QTimeZone>
|
|
||||||
#include <QUrl>
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#ifdef PDF_ENABLED
|
|
||||||
#include "components/pdf/PdfWidget.hpp"
|
|
||||||
#include <QtPdf/QPdfDocument>
|
|
||||||
#include <QtPdfWidgets/QPdfView>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#include "UriTools.hpp"
|
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <time.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
char *Utils::rstrstr(const char *a, const char *b) {
|
char *Utils::rstrstr(const char *a, const char *b) {
|
||||||
|
|
@ -61,909 +34,3 @@ char *Utils::rstrstr(const char *a, const char *b) {
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
namespace {
|
|
||||||
constexpr int SafeFilePathLimit = 100;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<linphone::Address> Utils::interpretUrl(const QString& address){
|
|
||||||
bool usePrefix = CoreManager::getInstance()->getAccountSettingsModel()->getUseInternationalPrefixForCallsAndChats();
|
|
||||||
auto interpretedAddress = CoreManager::getInstance()->getCore()->interpretUrl(Utils::appStringToCoreString(address),
|
|
||||||
usePrefix); if(!interpretedAddress){// Try by removing scheme. QStringList splitted = address.split(":");
|
|
||||||
if(splitted.size() > 0 && splitted[0] == "sip"){
|
|
||||||
splitted.removeFirst();
|
|
||||||
interpretedAddress =
|
|
||||||
CoreManager::getInstance()->getCore()->interpretUrl(Utils::appStringToCoreString(splitted.join(":")), usePrefix);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return interpretedAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
bool Utils::hasCapability(const QString& address, const LinphoneEnums::FriendCapability& capability, bool
|
|
||||||
defaultCapability){ auto addressCleaned = cleanSipAddress(address); auto contact =
|
|
||||||
CoreManager::getInstance()->getContactsListModel()->findContactModelFromSipAddress(addressCleaned); if(contact) return
|
|
||||||
contact->hasCapability(capability); else return defaultCapability;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
QDateTime Utils::addMinutes(QDateTime date, const int& min){
|
|
||||||
return date.addSecs(min*60);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDateTime Utils::getOffsettedUTC(const QDateTime& date){
|
|
||||||
QDateTime utc = date.toUTC();// Get a date free of any offsets.
|
|
||||||
auto timezone = date.timeZone();
|
|
||||||
utc = utc.addSecs(timezone.offsetFromUtc(date));// add offset from date timezone
|
|
||||||
utc.setTimeSpec(Qt::OffsetFromUTC);// ensure to have an UTC date
|
|
||||||
return utc;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Utils::toDateTimeString(QDateTime date, const QString& format){
|
|
||||||
if(date.date() == QDate::currentDate())
|
|
||||||
return toTimeString(date);
|
|
||||||
else{
|
|
||||||
return getOffsettedUTC(date).toString(format);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Utils::toTimeString(QDateTime date, const QString& format){
|
|
||||||
// Issue : date.toString() will not print the good time in timezones. Get it from date and add ourself the offset.
|
|
||||||
return getOffsettedUTC(date).toString(format);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Utils::toDateString(QDateTime date, const QString& format){
|
|
||||||
return QLocale().toString(getOffsettedUTC(date), (!format.isEmpty() ? format : QLocale().dateFormat()) );
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Utils::toDateString(QDate date, const QString& format){
|
|
||||||
return QLocale().toString(date, (!format.isEmpty() ? format : QLocale().dateFormat()) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return custom address to be displayed on UI.
|
|
||||||
// In order to return only the username and to remove all domains from the GUI, you may just change the default mode.
|
|
||||||
QString Utils::toDisplayString(const QString& str, SipDisplayMode displayMode){
|
|
||||||
if(displayMode == SIP_DISPLAY_ALL) return str;
|
|
||||||
std::shared_ptr<linphone::Address> addr = linphone::Factory::get()->createAddress(str.toStdString());
|
|
||||||
QString displayString;
|
|
||||||
if( addr && ( (displayMode & SIP_DISPLAY_USERNAME) == SIP_DISPLAY_USERNAME))
|
|
||||||
displayString = Utils::coreStringToAppString(addr->getUsername());
|
|
||||||
if(displayString.isEmpty())
|
|
||||||
return str;
|
|
||||||
else
|
|
||||||
return displayString;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDate Utils::getCurrentDate() {
|
|
||||||
return QDate::currentDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
DateModel* Utils::getCurrentDateModel() {
|
|
||||||
return new DateModel(QDate::currentDate());
|
|
||||||
}
|
|
||||||
|
|
||||||
QDate Utils::getMinDate() {
|
|
||||||
return QDate(1,1,1);
|
|
||||||
}
|
|
||||||
DateModel* Utils::getMinDateModel() {
|
|
||||||
return new DateModel(QDate(1,1,1));
|
|
||||||
}
|
|
||||||
QDate Utils::toDate(const QString& str, const QString& format) {
|
|
||||||
return QDate::fromString(str, format);
|
|
||||||
}
|
|
||||||
DateModel* Utils::toDateModel(const QString& str, const QString& format) {
|
|
||||||
return new DateModel(toDate(str, format));
|
|
||||||
}
|
|
||||||
QDate Utils::getDate(int year, int month, int day) {
|
|
||||||
auto d = QDate(year, month, day);
|
|
||||||
if(!d.isValid() ){
|
|
||||||
auto first = QDate(year, month, 1);
|
|
||||||
if(first.isValid()) {
|
|
||||||
d = first.addDays(day-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
DateModel* Utils::getDateModel(int year, int month, int day) {
|
|
||||||
auto d = QDate(year, month, day);
|
|
||||||
if(!d.isValid() ){
|
|
||||||
auto first = QDate(year, month, 1);
|
|
||||||
if(first.isValid()) {
|
|
||||||
d = first.addDays(day-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new DateModel(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Utils::getFullYear(const QDate& date) {
|
|
||||||
return date.year();
|
|
||||||
}
|
|
||||||
|
|
||||||
int Utils::getMonth(const QDate& date) {
|
|
||||||
return date.month();
|
|
||||||
}
|
|
||||||
|
|
||||||
int Utils::getDay(const QDate& date) {
|
|
||||||
return date.day();
|
|
||||||
}
|
|
||||||
|
|
||||||
int Utils::getDayOfWeek(const QDate& date) {
|
|
||||||
return date.dayOfWeek();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utils::equals(const QDate& d1, const QDate& d2){
|
|
||||||
return d1 == d2;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utils::isGreatherThan(const QDate& d1, const QDate& d2) {
|
|
||||||
return d1 >= d2;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
QString Utils::getDisplayName(const QString& address){
|
|
||||||
QString displayName = getDisplayName(interpretUrl(address));
|
|
||||||
return displayName.isEmpty() ? address : displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Utils::getInitials(const QString& username){
|
|
||||||
if(username.isEmpty()) return "";
|
|
||||||
|
|
||||||
QRegularExpression regex("[\\s\\.]+");
|
|
||||||
QStringList words = username.split(regex);// Qt 5.14: Qt::SkipEmptyParts
|
|
||||||
QStringList initials;
|
|
||||||
auto str32 = words[0].toStdU32String();
|
|
||||||
std::u32string char32;
|
|
||||||
char32 += str32[0];
|
|
||||||
initials << QString::fromStdU32String(char32);
|
|
||||||
for(int i = 1; i < words.size() && initials.size() <= 1 ; ++i) {
|
|
||||||
if( words[i].size() > 0){
|
|
||||||
str32 = words[i].toStdU32String();
|
|
||||||
char32[0] = str32[0];
|
|
||||||
initials << QString::fromStdU32String(char32);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return App::getInstance()->getLocale().toUpper(initials.join(""));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Utils::toString(const LinphoneEnums::TunnelMode& mode){
|
|
||||||
switch(mode){
|
|
||||||
case LinphoneEnums::TunnelMode::TunnelModeEnable :
|
|
||||||
//: 'Enable' : One word for button action to enable tunnel mode.
|
|
||||||
return QObject::tr("LinphoneEnums_TunnelModeEnable");
|
|
||||||
case LinphoneEnums::TunnelMode::TunnelModeDisable :
|
|
||||||
//: 'Disable' : One word for button action to disable tunnel mode.
|
|
||||||
return QObject::tr("LinphoneEnums_TunnelModeDisable");
|
|
||||||
case LinphoneEnums::TunnelMode::TunnelModeAuto :
|
|
||||||
//: 'Auto' : One word for button action to set the auto tunnel mode.
|
|
||||||
return QObject::tr("LinphoneEnums_TunnelModeAuto");
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QImage Utils::getImage(const QString &pUri) {
|
|
||||||
QImage image(pUri);
|
|
||||||
QImageReader reader(pUri);
|
|
||||||
reader.setAutoTransform(true);
|
|
||||||
if(image.isNull()){// Try to determine format from headers instead of using suffix
|
|
||||||
reader.setDecideFormatFromContent(true);
|
|
||||||
}
|
|
||||||
return reader.read();
|
|
||||||
}
|
|
||||||
QString Utils::getSafeFilePath (const QString &filePath, bool *soFarSoGood) {
|
|
||||||
if (soFarSoGood)
|
|
||||||
*soFarSoGood = true;
|
|
||||||
|
|
||||||
QFileInfo info(filePath);
|
|
||||||
if (!info.exists())
|
|
||||||
return filePath;
|
|
||||||
|
|
||||||
const QString prefix = QStringLiteral("%1/%2").arg(info.absolutePath()).arg(info.baseName());
|
|
||||||
const QString ext = info.completeSuffix();
|
|
||||||
|
|
||||||
for (int i = 1; i < SafeFilePathLimit; ++i) {
|
|
||||||
QString safePath = QStringLiteral("%1 (%3).%4").arg(prefix).arg(i).arg(ext);
|
|
||||||
if (!QFileInfo::exists(safePath))
|
|
||||||
return safePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (soFarSoGood)
|
|
||||||
*soFarSoGood = false;
|
|
||||||
|
|
||||||
return QString("");
|
|
||||||
}
|
|
||||||
std::shared_ptr<linphone::Address> Utils::getMatchingLocalAddress(std::shared_ptr<linphone::Address> p_localAddress){
|
|
||||||
QVector<std::shared_ptr<linphone::Address> > addresses;
|
|
||||||
// Get default account
|
|
||||||
addresses.push_back(CoreManager::getInstance()->getCore()->createPrimaryContactParsed());
|
|
||||||
auto accounts = CoreManager::getInstance()->getAccountList();
|
|
||||||
foreach(auto account, accounts)
|
|
||||||
addresses.push_back(account->getParams()->getIdentityAddress()->clone());
|
|
||||||
foreach(auto address, addresses){
|
|
||||||
if( address->getUsername() == p_localAddress->getUsername() && address->getDomain() ==
|
|
||||||
p_localAddress->getDomain()) return address;
|
|
||||||
}
|
|
||||||
return p_localAddress;
|
|
||||||
}
|
|
||||||
// Return at most : sip:username@domain
|
|
||||||
QString Utils::cleanSipAddress (const QString &sipAddress) {
|
|
||||||
std::shared_ptr<linphone::Address> addr = linphone::Factory::get()->createAddress(sipAddress.toStdString());
|
|
||||||
if( addr) {
|
|
||||||
addr->clean();
|
|
||||||
QStringList fields = Utils::coreStringToAppString(addr->asStringUriOnly()).split('@');
|
|
||||||
if(fields.size() > 0){// maybe useless but it's just to be sure to have a domain
|
|
||||||
fields.removeLast();
|
|
||||||
QString domain = Utils::coreStringToAppString(addr->getDomain());
|
|
||||||
if( domain.count(':')>1)
|
|
||||||
fields.append('['+domain+']');
|
|
||||||
else
|
|
||||||
fields.append(domain);
|
|
||||||
return fields.join('@');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sipAddress;
|
|
||||||
}
|
|
||||||
// Data to retrieve WIN32 process
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
struct EnumData {
|
|
||||||
DWORD dwProcessId;
|
|
||||||
HWND hWnd;
|
|
||||||
};
|
|
||||||
// Application-defined callback for EnumWindows
|
|
||||||
BOOL CALLBACK EnumProc(HWND hWnd, LPARAM lParam) {
|
|
||||||
// Retrieve storage location for communication data
|
|
||||||
EnumData& ed = *(EnumData*)lParam;
|
|
||||||
DWORD dwProcessId = 0x0;
|
|
||||||
// Query process ID for hWnd
|
|
||||||
GetWindowThreadProcessId(hWnd, &dwProcessId);
|
|
||||||
// Apply filter - if you want to implement additional restrictions,
|
|
||||||
// this is the place to do so.
|
|
||||||
if (ed.dwProcessId == dwProcessId) {
|
|
||||||
// Found a window matching the process ID
|
|
||||||
ed.hWnd = hWnd;
|
|
||||||
// Report success
|
|
||||||
SetLastError(ERROR_SUCCESS);
|
|
||||||
// Stop enumeration
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
// Continue enumeration
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
// Main entry
|
|
||||||
HWND FindWindowFromProcessId(DWORD dwProcessId) {
|
|
||||||
EnumData ed = { dwProcessId };
|
|
||||||
if (!EnumWindows(EnumProc, (LPARAM)&ed) &&
|
|
||||||
(GetLastError() == ERROR_SUCCESS)) {
|
|
||||||
return ed.hWnd;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper method for convenience
|
|
||||||
HWND FindWindowFromProcess(HANDLE hProcess) {
|
|
||||||
return FindWindowFromProcessId(GetProcessId(hProcess));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool Utils::processExists(const quint64& p_processId)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
return FindWindowFromProcessId(p_processId) != NULL;
|
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
QString Utils::getCountryName(const QLocale::Country& p_country)
|
|
||||||
{
|
|
||||||
QString countryName;
|
|
||||||
switch(p_country)
|
|
||||||
{
|
|
||||||
case QLocale::Afghanistan: if((countryName = QCoreApplication::translate("country", "Afghanistan"))==
|
|
||||||
"Afghanistan") countryName = "";break; case QLocale::Albania: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Albania"))== "Albania") countryName = "";break; case QLocale::Algeria: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Algeria"))== "Algeria") countryName = "";break; case QLocale::AmericanSamoa:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "AmericanSamoa"))== "AmericanSamoa") countryName = "";break;
|
|
||||||
case QLocale::Andorra: if((countryName = QCoreApplication::translate("country", "Andorra"))== "Andorra")
|
|
||||||
countryName = "";break; case QLocale::Angola: if((countryName = QCoreApplication::translate("country", "Angola"))==
|
|
||||||
"Angola") countryName = "";break; case QLocale::Anguilla: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Anguilla"))== "Anguilla") countryName = "";break; case QLocale::AntiguaAndBarbuda: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "AntiguaAndBarbuda"))== "AntiguaAndBarbuda") countryName = "";break; case
|
|
||||||
QLocale::Argentina: if((countryName = QCoreApplication::translate("country", "Argentina"))== "Argentina") countryName =
|
|
||||||
"";break; case QLocale::Armenia: if((countryName = QCoreApplication::translate("country", "Armenia"))== "Armenia")
|
|
||||||
countryName = "";break; case QLocale::Aruba: if((countryName = QCoreApplication::translate("country", "Aruba"))==
|
|
||||||
"Aruba") countryName = "";break; case QLocale::Australia: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Australia"))== "Australia") countryName = "";break; case QLocale::Austria: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Austria"))== "Austria") countryName = "";break; case QLocale::Azerbaijan:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Azerbaijan"))== "Azerbaijan") countryName = "";break; case
|
|
||||||
QLocale::Bahamas: if((countryName = QCoreApplication::translate("country", "Bahamas"))== "Bahamas") countryName =
|
|
||||||
"";break; case QLocale::Bahrain: if((countryName = QCoreApplication::translate("country", "Bahrain"))== "Bahrain")
|
|
||||||
countryName = "";break; case QLocale::Bangladesh: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Bangladesh"))== "Bangladesh") countryName = "";break; case QLocale::Barbados: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Barbados"))== "Barbados") countryName = "";break; case QLocale::Belarus:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Belarus"))== "Belarus") countryName = "";break; case
|
|
||||||
QLocale::Belgium: if((countryName = QCoreApplication::translate("country", "Belgium"))== "Belgium") countryName =
|
|
||||||
"";break; case QLocale::Belize: if((countryName = QCoreApplication::translate("country", "Belize"))== "Belize")
|
|
||||||
countryName = "";break; case QLocale::Benin: if((countryName = QCoreApplication::translate("country", "Benin"))==
|
|
||||||
"Benin") countryName = "";break; case QLocale::Bermuda: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Bermuda"))== "Bermuda") countryName = "";break; case QLocale::Bhutan: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Bhutan"))== "Bhutan") countryName = "";break; case QLocale::Bolivia:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Bolivia"))== "Bolivia") countryName = "";break; case
|
|
||||||
QLocale::BosniaAndHerzegowina: if((countryName = QCoreApplication::translate("country", "BosniaAndHerzegowina"))==
|
|
||||||
"BosniaAndHerzegowina") countryName = "";break; case QLocale::Botswana: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Botswana"))== "Botswana") countryName = "";break; case QLocale::Brazil:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Brazil"))== "Brazil") countryName = "";break; case
|
|
||||||
QLocale::Brunei: if((countryName = QCoreApplication::translate("country", "Brunei"))== "Brunei") countryName = "";break;
|
|
||||||
case QLocale::Bulgaria: if((countryName = QCoreApplication::translate("country", "Bulgaria"))== "Bulgaria")
|
|
||||||
countryName = "";break; case QLocale::BurkinaFaso: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"BurkinaFaso"))== "BurkinaFaso") countryName = "";break; case QLocale::Burundi: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Burundi"))== "Burundi") countryName = "";break; case QLocale::Cambodia:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Cambodia"))== "Cambodia") countryName = "";break; case
|
|
||||||
QLocale::Cameroon: if((countryName = QCoreApplication::translate("country", "Cameroon"))== "Cameroon") countryName =
|
|
||||||
"";break; case QLocale::Canada: if((countryName = QCoreApplication::translate("country", "Canada"))== "Canada")
|
|
||||||
countryName = "";break; case QLocale::CapeVerde: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"CapeVerde"))== "CapeVerde") countryName = "";break; case QLocale::CaymanIslands: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "CaymanIslands"))== "CaymanIslands") countryName = "";break; case
|
|
||||||
QLocale::CentralAfricanRepublic: if((countryName = QCoreApplication::translate("country", "CentralAfricanRepublic"))==
|
|
||||||
"CentralAfricanRepublic") countryName = "";break; case QLocale::Chad: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Chad"))== "Chad") countryName = "";break; case QLocale::Chile: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Chile"))== "Chile") countryName = "";break; case QLocale::China: if((countryName
|
|
||||||
= QCoreApplication::translate("country", "China"))== "China") countryName = "";break; case QLocale::Colombia:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Colombia"))== "Colombia") countryName = "";break; case
|
|
||||||
QLocale::Comoros: if((countryName = QCoreApplication::translate("country", "Comoros"))== "Comoros") countryName =
|
|
||||||
"";break; case QLocale::PeoplesRepublicOfCongo: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"PeoplesRepublicOfCongo"))== "PeoplesRepublicOfCongo") countryName = "";break; case QLocale::DemocraticRepublicOfCongo:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "DemocraticRepublicOfCongo"))== "DemocraticRepublicOfCongo")
|
|
||||||
countryName = "";break; case QLocale::CookIslands: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"CookIslands"))== "CookIslands") countryName = "";break; case QLocale::CostaRica: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "CostaRica"))== "CostaRica") countryName = "";break; case QLocale::IvoryCoast:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "IvoryCoast"))== "IvoryCoast") countryName = "";break; case
|
|
||||||
QLocale::Croatia: if((countryName = QCoreApplication::translate("country", "Croatia"))== "Croatia") countryName =
|
|
||||||
"";break; case QLocale::Cuba: if((countryName = QCoreApplication::translate("country", "Cuba"))== "Cuba") countryName =
|
|
||||||
"";break; case QLocale::Cyprus: if((countryName = QCoreApplication::translate("country", "Cyprus"))== "Cyprus")
|
|
||||||
countryName = "";break; case QLocale::CzechRepublic: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"CzechRepublic"))== "CzechRepublic") countryName = "";break; case QLocale::Denmark: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Denmark"))== "Denmark") countryName = "";break; case QLocale::Djibouti:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Djibouti"))== "Djibouti") countryName = "";break; case
|
|
||||||
QLocale::Dominica: if((countryName = QCoreApplication::translate("country", "Dominica"))== "Dominica") countryName =
|
|
||||||
"";break; case QLocale::DominicanRepublic: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"DominicanRepublic"))== "DominicanRepublic") countryName = "";break; case QLocale::Ecuador: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Ecuador"))== "Ecuador") countryName = "";break; case QLocale::Egypt:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Egypt"))== "Egypt") countryName = "";break; case
|
|
||||||
QLocale::ElSalvador: if((countryName = QCoreApplication::translate("country", "ElSalvador"))== "ElSalvador") countryName
|
|
||||||
= "";break; case QLocale::EquatorialGuinea: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"EquatorialGuinea"))== "EquatorialGuinea") countryName = "";break; case QLocale::Eritrea: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Eritrea"))== "Eritrea") countryName = "";break; case QLocale::Estonia:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Estonia"))== "Estonia") countryName = "";break; case
|
|
||||||
QLocale::Ethiopia: if((countryName = QCoreApplication::translate("country", "Ethiopia"))== "Ethiopia") countryName =
|
|
||||||
"";break; case QLocale::FalklandIslands: if((countryName = QCoreApplication::translate("country", "FalklandIslands"))==
|
|
||||||
"FalklandIslands") countryName = "";break; case QLocale::FaroeIslands: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "FaroeIslands"))== "FaroeIslands") countryName = "";break; case QLocale::Fiji:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Fiji"))== "Fiji") countryName = "";break; case
|
|
||||||
QLocale::Finland: if((countryName = QCoreApplication::translate("country", "Finland"))== "Finland") countryName =
|
|
||||||
"";break; case QLocale::France: if((countryName = QCoreApplication::translate("country", "France"))== "France")
|
|
||||||
countryName = "";break; case QLocale::FrenchGuiana: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"FrenchGuiana"))== "FrenchGuiana") countryName = "";break; case QLocale::FrenchPolynesia: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "FrenchPolynesia"))== "FrenchPolynesia") countryName = "";break; case
|
|
||||||
QLocale::Gabon: if((countryName = QCoreApplication::translate("country", "Gabon"))== "Gabon") countryName = "";break;
|
|
||||||
case QLocale::Gambia: if((countryName = QCoreApplication::translate("country", "Gambia"))== "Gambia")
|
|
||||||
countryName = "";break; case QLocale::Georgia: if((countryName = QCoreApplication::translate("country", "Georgia"))==
|
|
||||||
"Georgia") countryName = "";break; case QLocale::Germany: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Germany"))== "Germany") countryName = "";break; case QLocale::Ghana: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Ghana"))== "Ghana") countryName = "";break; case QLocale::Gibraltar:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Gibraltar"))== "Gibraltar") countryName = "";break; case
|
|
||||||
QLocale::Greece: if((countryName = QCoreApplication::translate("country", "Greece"))== "Greece") countryName = "";break;
|
|
||||||
case QLocale::Greenland: if((countryName = QCoreApplication::translate("country", "Greenland"))== "Greenland")
|
|
||||||
countryName = "";break; case QLocale::Grenada: if((countryName = QCoreApplication::translate("country", "Grenada"))==
|
|
||||||
"Grenada") countryName = "";break; case QLocale::Guadeloupe: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Guadeloupe"))== "Guadeloupe") countryName = "";break; case QLocale::Guam: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Guam"))== "Guam") countryName = "";break; case QLocale::Guatemala:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Guatemala"))== "Guatemala") countryName = "";break; case
|
|
||||||
QLocale::Guinea: if((countryName = QCoreApplication::translate("country", "Guinea"))== "Guinea") countryName = "";break;
|
|
||||||
case QLocale::GuineaBissau: if((countryName = QCoreApplication::translate("country", "GuineaBissau"))==
|
|
||||||
"GuineaBissau") countryName = "";break; case QLocale::Guyana: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Guyana"))== "Guyana") countryName = "";break; case QLocale::Haiti: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Haiti"))== "Haiti") countryName = "";break; case QLocale::Honduras:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Honduras"))== "Honduras") countryName = "";break; case
|
|
||||||
QLocale::HongKong: if((countryName = QCoreApplication::translate("country", "HongKong"))== "HongKong") countryName =
|
|
||||||
"";break; case QLocale::Hungary: if((countryName = QCoreApplication::translate("country", "Hungary"))== "Hungary")
|
|
||||||
countryName = "";break; case QLocale::Iceland: if((countryName = QCoreApplication::translate("country", "Iceland"))==
|
|
||||||
"Iceland") countryName = "";break; case QLocale::India: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"India"))== "India") countryName = "";break; case QLocale::Indonesia: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Indonesia"))== "Indonesia") countryName = "";break; case QLocale::Iran:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Iran"))== "Iran") countryName = "";break; case QLocale::Iraq:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Iraq"))== "Iraq") countryName = "";break; case
|
|
||||||
QLocale::Ireland: if((countryName = QCoreApplication::translate("country", "Ireland"))== "Ireland") countryName =
|
|
||||||
"";break; case QLocale::Israel: if((countryName = QCoreApplication::translate("country", "Israel"))== "Israel")
|
|
||||||
countryName = "";break; case QLocale::Italy: if((countryName = QCoreApplication::translate("country", "Italy"))==
|
|
||||||
"Italy") countryName = "";break; case QLocale::Jamaica: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Jamaica"))== "Jamaica") countryName = "";break; case QLocale::Japan: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Japan"))== "Japan") countryName = "";break; case QLocale::Jordan:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Jordan"))== "Jordan") countryName = "";break; case
|
|
||||||
QLocale::Kazakhstan: if((countryName = QCoreApplication::translate("country", "Kazakhstan"))== "Kazakhstan") countryName
|
|
||||||
= "";break; case QLocale::Kenya: if((countryName = QCoreApplication::translate("country", "Kenya"))== "Kenya")
|
|
||||||
countryName = "";break; case QLocale::Kiribati: if((countryName = QCoreApplication::translate("country", "Kiribati"))==
|
|
||||||
"Kiribati") countryName = "";break; case QLocale::DemocraticRepublicOfKorea: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "DemocraticRepublicOfKorea"))== "DemocraticRepublicOfKorea") countryName =
|
|
||||||
"";break; case QLocale::RepublicOfKorea: if((countryName = QCoreApplication::translate("country", "RepublicOfKorea"))==
|
|
||||||
"RepublicOfKorea") countryName = "";break; case QLocale::Kuwait: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Kuwait"))== "Kuwait") countryName = "";break; case QLocale::Kyrgyzstan:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Kyrgyzstan"))== "Kyrgyzstan") countryName = "";break; case
|
|
||||||
QLocale::Laos: if((countryName = QCoreApplication::translate("country", "Laos"))== "Laos") countryName = "";break; case
|
|
||||||
QLocale::Latvia: if((countryName = QCoreApplication::translate("country", "Latvia"))== "Latvia") countryName = "";break;
|
|
||||||
case QLocale::Lebanon: if((countryName = QCoreApplication::translate("country", "Lebanon"))== "Lebanon")
|
|
||||||
countryName = "";break; case QLocale::Lesotho: if((countryName = QCoreApplication::translate("country", "Lesotho"))==
|
|
||||||
"Lesotho") countryName = "";break; case QLocale::Liberia: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Liberia"))== "Liberia") countryName = "";break; case QLocale::Libya: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Libya"))== "Libya") countryName = "";break; case QLocale::Liechtenstein:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Liechtenstein"))== "Liechtenstein") countryName = "";break;
|
|
||||||
case QLocale::Lithuania: if((countryName = QCoreApplication::translate("country", "Lithuania"))== "Lithuania")
|
|
||||||
countryName = "";break; case QLocale::Luxembourg: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Luxembourg"))== "Luxembourg") countryName = "";break; case QLocale::Macau: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Macau"))== "Macau") countryName = "";break; case QLocale::Macedonia:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Macedonia"))== "Macedonia") countryName = "";break; case
|
|
||||||
QLocale::Madagascar: if((countryName = QCoreApplication::translate("country", "Madagascar"))== "Madagascar") countryName
|
|
||||||
= "";break; case QLocale::Malawi: if((countryName = QCoreApplication::translate("country", "Malawi"))== "Malawi")
|
|
||||||
countryName = "";break; case QLocale::Malaysia: if((countryName = QCoreApplication::translate("country", "Malaysia"))==
|
|
||||||
"Malaysia") countryName = "";break; case QLocale::Maldives: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Maldives"))== "Maldives") countryName = "";break; case QLocale::Mali: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Mali"))== "Mali") countryName = "";break; case QLocale::Malta: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Malta"))== "Malta") countryName = "";break; case QLocale::MarshallIslands:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "MarshallIslands"))== "MarshallIslands") countryName =
|
|
||||||
"";break; case QLocale::Martinique: if((countryName = QCoreApplication::translate("country", "Martinique"))==
|
|
||||||
"Martinique") countryName = "";break; case QLocale::Mauritania: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Mauritania"))== "Mauritania") countryName = "";break; case QLocale::Mauritius: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Mauritius"))== "Mauritius") countryName = "";break; case QLocale::Mayotte:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Mayotte"))== "Mayotte") countryName = "";break; case
|
|
||||||
QLocale::Mexico: if((countryName = QCoreApplication::translate("country", "Mexico"))== "Mexico") countryName = "";break;
|
|
||||||
case QLocale::Micronesia: if((countryName = QCoreApplication::translate("country", "Micronesia"))==
|
|
||||||
"Micronesia") countryName = "";break; case QLocale::Moldova: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Moldova"))== "Moldova") countryName = "";break; case QLocale::Monaco: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Monaco"))== "Monaco") countryName = "";break; case QLocale::Mongolia:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Mongolia"))== "Mongolia") countryName = "";break; case
|
|
||||||
QLocale::Montenegro: if((countryName = QCoreApplication::translate("country", "Montenegro"))== "Montenegro") countryName
|
|
||||||
= "";break; case QLocale::Montserrat: if((countryName = QCoreApplication::translate("country", "Montserrat"))==
|
|
||||||
"Montserrat") countryName = "";break; case QLocale::Morocco: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Morocco"))== "Morocco") countryName = "";break; case QLocale::Mozambique: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Mozambique"))== "Mozambique") countryName = "";break; case QLocale::Myanmar:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Myanmar"))== "Myanmar") countryName = "";break; case
|
|
||||||
QLocale::Namibia: if((countryName = QCoreApplication::translate("country", "Namibia"))== "Namibia") countryName =
|
|
||||||
"";break; case QLocale::NauruCountry: if((countryName = QCoreApplication::translate("country", "NauruCountry"))==
|
|
||||||
"NauruCountry") countryName = "";break; case QLocale::Nepal: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Nepal"))== "Nepal") countryName = "";break; case QLocale::Netherlands: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Netherlands"))== "Netherlands") countryName = "";break; case
|
|
||||||
QLocale::NewCaledonia: if((countryName = QCoreApplication::translate("country", "NewCaledonia"))== "NewCaledonia")
|
|
||||||
countryName = "";break; case QLocale::NewZealand: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"NewZealand"))== "NewZealand") countryName = "";break; case QLocale::Nicaragua: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Nicaragua"))== "Nicaragua") countryName = "";break; case QLocale::Niger:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Niger"))== "Niger") countryName = "";break; case
|
|
||||||
QLocale::Nigeria: if((countryName = QCoreApplication::translate("country", "Nigeria"))== "Nigeria") countryName =
|
|
||||||
"";break; case QLocale::Niue: if((countryName = QCoreApplication::translate("country", "Niue"))== "Niue") countryName =
|
|
||||||
"";break; case QLocale::NorfolkIsland: if((countryName = QCoreApplication::translate("country", "NorfolkIsland"))==
|
|
||||||
"NorfolkIsland") countryName = "";break; case QLocale::NorthernMarianaIslands: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "NorthernMarianaIslands"))== "NorthernMarianaIslands") countryName = "";break;
|
|
||||||
case QLocale::Norway: if((countryName = QCoreApplication::translate("country", "Norway"))== "Norway")
|
|
||||||
countryName = "";break; case QLocale::Oman: if((countryName = QCoreApplication::translate("country", "Oman"))== "Oman")
|
|
||||||
countryName = "";break; case QLocale::Pakistan: if((countryName = QCoreApplication::translate("country", "Pakistan"))==
|
|
||||||
"Pakistan") countryName = "";break; case QLocale::Palau: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Palau"))== "Palau") countryName = "";break; case QLocale::PalestinianTerritories: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "PalestinianTerritories"))== "PalestinianTerritories") countryName = "";break;
|
|
||||||
case QLocale::Panama: if((countryName = QCoreApplication::translate("country", "Panama"))== "Panama")
|
|
||||||
countryName = "";break; case QLocale::PapuaNewGuinea: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"PapuaNewGuinea"))== "PapuaNewGuinea") countryName = "";break; case QLocale::Paraguay: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Paraguay"))== "Paraguay") countryName = "";break; case QLocale::Peru:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Peru"))== "Peru") countryName = "";break; case
|
|
||||||
QLocale::Philippines: if((countryName = QCoreApplication::translate("country", "Philippines"))== "Philippines")
|
|
||||||
countryName = "";break; case QLocale::Poland: if((countryName = QCoreApplication::translate("country", "Poland"))==
|
|
||||||
"Poland") countryName = "";break; case QLocale::Portugal: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Portugal"))== "Portugal") countryName = "";break; case QLocale::PuertoRico: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "PuertoRico"))== "PuertoRico") countryName = "";break; case QLocale::Qatar:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Qatar"))== "Qatar") countryName = "";break; case
|
|
||||||
QLocale::Reunion: if((countryName = QCoreApplication::translate("country", "Reunion"))== "Reunion") countryName =
|
|
||||||
"";break; case QLocale::Romania: if((countryName = QCoreApplication::translate("country", "Romania"))== "Romania")
|
|
||||||
countryName = "";break; case QLocale::RussianFederation: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"RussianFederation"))== "RussianFederation") countryName = "";break; case QLocale::Rwanda: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Rwanda"))== "Rwanda") countryName = "";break; case QLocale::SaintHelena:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "SaintHelena"))== "SaintHelena") countryName = "";break; case
|
|
||||||
QLocale::SaintKittsAndNevis: if((countryName = QCoreApplication::translate("country", "SaintKittsAndNevis"))==
|
|
||||||
"SaintKittsAndNevis") countryName = "";break; case QLocale::SaintLucia: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "SaintLucia"))== "SaintLucia") countryName = "";break; case
|
|
||||||
QLocale::SaintPierreAndMiquelon: if((countryName = QCoreApplication::translate("country", "SaintPierreAndMiquelon"))==
|
|
||||||
"SaintPierreAndMiquelon") countryName = "";break; case QLocale::SaintVincentAndTheGrenadines: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "SaintVincentAndTheGrenadines"))== "SaintVincentAndTheGrenadines") countryName =
|
|
||||||
"";break; case QLocale::Samoa: if((countryName = QCoreApplication::translate("country", "Samoa"))== "Samoa") countryName
|
|
||||||
= "";break; case QLocale::SanMarino: if((countryName = QCoreApplication::translate("country", "SanMarino"))==
|
|
||||||
"SanMarino") countryName = "";break; case QLocale::SaoTomeAndPrincipe: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "SaoTomeAndPrincipe"))== "SaoTomeAndPrincipe") countryName = "";break; case
|
|
||||||
QLocale::SaudiArabia: if((countryName = QCoreApplication::translate("country", "SaudiArabia"))== "SaudiArabia")
|
|
||||||
countryName = "";break; case QLocale::Senegal: if((countryName = QCoreApplication::translate("country", "Senegal"))==
|
|
||||||
"Senegal") countryName = "";break; case QLocale::Serbia: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Serbia"))== "Serbia") countryName = "";break; case QLocale::Seychelles: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Seychelles"))== "Seychelles") countryName = "";break; case QLocale::SierraLeone:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "SierraLeone"))== "SierraLeone") countryName = "";break; case
|
|
||||||
QLocale::Singapore: if((countryName = QCoreApplication::translate("country", "Singapore"))== "Singapore") countryName =
|
|
||||||
"";break; case QLocale::Slovakia: if((countryName = QCoreApplication::translate("country", "Slovakia"))== "Slovakia")
|
|
||||||
countryName = "";break; case QLocale::Slovenia: if((countryName = QCoreApplication::translate("country", "Slovenia"))==
|
|
||||||
"Slovenia") countryName = "";break; case QLocale::SolomonIslands: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "SolomonIslands"))== "SolomonIslands") countryName = "";break; case
|
|
||||||
QLocale::Somalia: if((countryName = QCoreApplication::translate("country", "Somalia"))== "Somalia") countryName =
|
|
||||||
"";break; case QLocale::SouthAfrica: if((countryName = QCoreApplication::translate("country", "SouthAfrica"))==
|
|
||||||
"SouthAfrica") countryName = "";break; case QLocale::Spain: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Spain"))== "Spain") countryName = "";break; case QLocale::SriLanka: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "SriLanka"))== "SriLanka") countryName = "";break; case QLocale::Sudan:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Sudan"))== "Sudan") countryName = "";break; case
|
|
||||||
QLocale::Suriname: if((countryName = QCoreApplication::translate("country", "Suriname"))== "Suriname") countryName =
|
|
||||||
"";break; case QLocale::Swaziland: if((countryName = QCoreApplication::translate("country", "Swaziland"))== "Swaziland")
|
|
||||||
countryName = "";break; case QLocale::Sweden: if((countryName = QCoreApplication::translate("country", "Sweden"))==
|
|
||||||
"Sweden") countryName = "";break; case QLocale::Switzerland: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Switzerland"))== "Switzerland") countryName = "";break; case QLocale::Syria: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Syria"))== "Syria") countryName = "";break; case QLocale::Taiwan:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Taiwan"))== "Taiwan") countryName = "";break; case
|
|
||||||
QLocale::Tajikistan: if((countryName = QCoreApplication::translate("country", "Tajikistan"))== "Tajikistan") countryName
|
|
||||||
= "";break; case QLocale::Tanzania: if((countryName = QCoreApplication::translate("country", "Tanzania"))== "Tanzania")
|
|
||||||
countryName = "";break; case QLocale::Thailand: if((countryName = QCoreApplication::translate("country", "Thailand"))==
|
|
||||||
"Thailand") countryName = "";break; case QLocale::Togo: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Togo"))== "Togo") countryName = "";break; case QLocale::Tokelau: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Tokelau"))== "Tokelau") countryName = "";break; case QLocale::Tonga:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Tonga"))== "Tonga") countryName = "";break; case
|
|
||||||
QLocale::TrinidadAndTobago: if((countryName = QCoreApplication::translate("country", "TrinidadAndTobago"))==
|
|
||||||
"TrinidadAndTobago") countryName = "";break; case QLocale::Tunisia: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Tunisia"))== "Tunisia") countryName = "";break; case QLocale::Turkey:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Turkey"))== "Turkey") countryName = "";break; case
|
|
||||||
QLocale::Turkmenistan: if((countryName = QCoreApplication::translate("country", "Turkmenistan"))== "Turkmenistan")
|
|
||||||
countryName = "";break; case QLocale::TurksAndCaicosIslands: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"TurksAndCaicosIslands"))== "TurksAndCaicosIslands") countryName = "";break; case QLocale::Tuvalu: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Tuvalu"))== "Tuvalu") countryName = "";break; case QLocale::Uganda:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Uganda"))== "Uganda") countryName = "";break; case
|
|
||||||
QLocale::Ukraine: if((countryName = QCoreApplication::translate("country", "Ukraine"))== "Ukraine") countryName =
|
|
||||||
"";break; case QLocale::UnitedArabEmirates: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"UnitedArabEmirates"))== "UnitedArabEmirates") countryName = "";break; case QLocale::UnitedKingdom: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "UnitedKingdom"))== "UnitedKingdom") countryName = "";break; case
|
|
||||||
QLocale::UnitedStates: if((countryName = QCoreApplication::translate("country", "UnitedStates"))== "UnitedStates")
|
|
||||||
countryName = "";break; case QLocale::Uruguay: if((countryName = QCoreApplication::translate("country", "Uruguay"))==
|
|
||||||
"Uruguay") countryName = "";break; case QLocale::Uzbekistan: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"Uzbekistan"))== "Uzbekistan") countryName = "";break; case QLocale::Vanuatu: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Vanuatu"))== "Vanuatu") countryName = "";break; case QLocale::Venezuela:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Venezuela"))== "Venezuela") countryName = "";break; case
|
|
||||||
QLocale::Vietnam: if((countryName = QCoreApplication::translate("country", "Vietnam"))== "Vietnam") countryName =
|
|
||||||
"";break; case QLocale::WallisAndFutunaIslands: if((countryName = QCoreApplication::translate("country",
|
|
||||||
"WallisAndFutunaIslands"))== "WallisAndFutunaIslands") countryName = "";break; case QLocale::Yemen: if((countryName =
|
|
||||||
QCoreApplication::translate("country", "Yemen"))== "Yemen") countryName = "";break; case QLocale::Zambia:
|
|
||||||
if((countryName = QCoreApplication::translate("country", "Zambia"))== "Zambia") countryName = "";break; case
|
|
||||||
QLocale::Zimbabwe: if((countryName = QCoreApplication::translate("country", "Zimbabwe"))== "Zimbabwe") countryName =
|
|
||||||
"";break; default: { countryName = QLocale::countryToString(p_country);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( countryName == "")
|
|
||||||
countryName = QLocale::countryToString(p_country);
|
|
||||||
return countryName;
|
|
||||||
}
|
|
||||||
// Copy a folder recursively without erasing old file
|
|
||||||
void Utils::copyDir(QString from, QString to) {
|
|
||||||
QDir dir;
|
|
||||||
dir.setPath(from);
|
|
||||||
from += QDir::separator();
|
|
||||||
to += QDir::separator();
|
|
||||||
foreach (QString copyFile, dir.entryList(QDir::Files)) {// Copy each files
|
|
||||||
QString toFile = to + copyFile;
|
|
||||||
if (!QFile::exists(toFile))
|
|
||||||
QFile::copy(from+copyFile, toFile);
|
|
||||||
}
|
|
||||||
foreach (QString nextDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {// Copy folder
|
|
||||||
QString toDir = to + nextDir;
|
|
||||||
QDir().mkpath(toDir);// no need to check if dir exists
|
|
||||||
copyDir(from + nextDir, toDir);//Go up
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Utils::getDisplayName(const std::shared_ptr<const linphone::Address>& address){
|
|
||||||
QString displayName;
|
|
||||||
if(address){
|
|
||||||
displayName = CoreManager::getInstance()->getSipAddressesModel()->getDisplayName(address);
|
|
||||||
}
|
|
||||||
return displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<linphone::Config> Utils::getConfigIfExists (const QString &configPath) {
|
|
||||||
std::string factoryPath(Paths::getFactoryConfigFilePath());
|
|
||||||
if (!Paths::filePathExists(factoryPath))
|
|
||||||
factoryPath.clear();
|
|
||||||
|
|
||||||
return linphone::Config::newWithFactory(configPath.toStdString(), factoryPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Utils::getApplicationProduct(){
|
|
||||||
// Note: Keep '-' as a separator between application name and application type
|
|
||||||
return QString(APPLICATION_NAME"-Desktop").remove(' ')+"/"+QCoreApplication::applicationVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Utils::getOsProduct(){
|
|
||||||
QString version = QSysInfo::productVersion().remove(' ');// A version can be "Server 2016" (for Windows Server 2016)
|
|
||||||
QString product = QSysInfo::productType().replace(' ', '-'); // Just in case
|
|
||||||
return product+"/"+version;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Utils::computeUserAgent(const std::shared_ptr<linphone::Config>& config){
|
|
||||||
return QStringLiteral("%1 (%2) %3 Qt/%4 LinphoneSDK")
|
|
||||||
.arg(Utils::getApplicationProduct())
|
|
||||||
.arg(SettingsModel::getDeviceName(config)
|
|
||||||
.replace('\\', "\\\\")
|
|
||||||
.replace('(', "\\(")
|
|
||||||
.replace(')', "\\)")
|
|
||||||
)
|
|
||||||
.arg(Utils::getOsProduct())
|
|
||||||
.arg(qVersion());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utils::isMe(const QString& address){
|
|
||||||
return !address.isEmpty() ?
|
|
||||||
CoreManager::getInstance()->getAccountSettingsModel()->getUsedSipAddress()->weakEqual(Utils::interpretUrl(address)) :
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utils::isMe(const std::shared_ptr<const linphone::Address>& address){
|
|
||||||
return address ? CoreManager::getInstance()->getAccountSettingsModel()->getUsedSipAddress()->weakEqual(address) :
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utils::isAnimatedImage(const QString& path){
|
|
||||||
if(path.isEmpty()) return false;
|
|
||||||
QFileInfo info(path);
|
|
||||||
if( !info.exists() || !QMimeDatabase().mimeTypeForFile(info).name().contains("image/"))
|
|
||||||
return false;
|
|
||||||
QImageReader reader(path);
|
|
||||||
return reader.canRead() && reader.supportsAnimation() && reader.imageCount() > 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utils::isImage(const QString& path){
|
|
||||||
if(path.isEmpty()) return false;
|
|
||||||
QFileInfo info(path);
|
|
||||||
if( !info.exists() || CoreManager::getInstance()->getSettingsModel()->getVfsEncrypted()){
|
|
||||||
return QMimeDatabase().mimeTypeForFile(info, QMimeDatabase::MatchExtension).name().contains("image/");
|
|
||||||
}else if(!QMimeDatabase().mimeTypeForFile(info).name().contains("image/"))
|
|
||||||
return false;
|
|
||||||
QImageReader reader(path);
|
|
||||||
return reader.canRead() && reader.imageCount() == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utils::isVideo(const QString& path){
|
|
||||||
if(path.isEmpty()) return false;
|
|
||||||
return QMimeDatabase().mimeTypeForFile(path).name().contains("video/");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utils::isPdf(const QString& path){
|
|
||||||
if(path.isEmpty()) return false;
|
|
||||||
return QMimeDatabase().mimeTypeForFile(path).name().contains("application/pdf");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utils::isSupportedForDisplay(const QString& path){
|
|
||||||
if(path.isEmpty()) return false;
|
|
||||||
return !QMimeDatabase().mimeTypeForFile(path).name().contains("application");// "for pdf : "application/pdf". Note :
|
|
||||||
Make an exception when supported.
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utils::canHaveThumbnail(const QString& path){
|
|
||||||
if(path.isEmpty()) return false;
|
|
||||||
return isImage(path) || isAnimatedImage(path) || isPdf(path) || isVideo(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utils::isPhoneNumber(const QString& txt){
|
|
||||||
auto core = CoreManager::getInstance()->getCore();
|
|
||||||
if(!core)
|
|
||||||
return false;
|
|
||||||
auto account = core->getDefaultAccount();
|
|
||||||
return account && account->isPhoneNumber(Utils::appStringToCoreString(txt));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utils::isUsername(const QString& txt){
|
|
||||||
QRegularExpression regex("^(<?sips?:)?[a-zA-Z0-9+_.\\-]+>?$");
|
|
||||||
QRegularExpressionMatch match = regex.match(txt);
|
|
||||||
return match.hasMatch(); // true
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utils::isValidUrl(const QString& url){
|
|
||||||
return QUrl(url).isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize Utils::getImageSize(const QString& url){
|
|
||||||
QString path;
|
|
||||||
QUrl urlDecode(url);
|
|
||||||
if(urlDecode.isLocalFile())
|
|
||||||
path = QDir::toNativeSeparators(urlDecode.toLocalFile());
|
|
||||||
else
|
|
||||||
path = url;
|
|
||||||
QFileInfo info(path);
|
|
||||||
if( !info.exists())
|
|
||||||
return QSize(0,0);
|
|
||||||
QImageReader reader(path);
|
|
||||||
QSize s = reader.size();
|
|
||||||
if( s.isValid())
|
|
||||||
return s;
|
|
||||||
else
|
|
||||||
return QSize(0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
QPoint Utils::getCursorPosition(){
|
|
||||||
return QCursor::pos();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Utils::getFileChecksum(const QString& filePath){
|
|
||||||
QFile file(filePath);
|
|
||||||
if (file.open(QFile::ReadOnly)) {
|
|
||||||
QCryptographicHash hash(QCryptographicHash::Sha256);
|
|
||||||
if (hash.addData(&file)) {
|
|
||||||
return hash.result().toHex();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
bool Utils::codepointIsEmoji(uint code){
|
|
||||||
return (code >= 0x2600 && code <= 0x27bf) || (code >= 0x2b00 && code <= 0x2bff) ||
|
|
||||||
(code >= 0x1f000 && code <= 0x1faff) || code == 0x200d || code == 0xfe0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utils::codepointIsVisible(uint code) {
|
|
||||||
return code > 0x00020;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Utils::encodeEmojiToQmlRichFormat(const QString &body){
|
|
||||||
QString fmtBody = "";
|
|
||||||
QVector<uint> utf32_string = body.toUcs4();
|
|
||||||
|
|
||||||
bool insideFontBlock = false;
|
|
||||||
for (auto &code : utf32_string) {
|
|
||||||
if (Utils::codepointIsEmoji(code)) {
|
|
||||||
if (!insideFontBlock) {
|
|
||||||
fmtBody += QString("<font face=\"" +
|
|
||||||
CoreManager::getInstance()->getSettingsModel()->getEmojiFont().family() + "\">");
|
|
||||||
insideFontBlock = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (insideFontBlock) {
|
|
||||||
fmtBody += "</font>";
|
|
||||||
insideFontBlock = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fmtBody += QString::fromUcs4(&code, 1);
|
|
||||||
}
|
|
||||||
if (insideFontBlock) {
|
|
||||||
fmtBody += "</font>";
|
|
||||||
}
|
|
||||||
return fmtBody;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utils::isOnlyEmojis(const QString& text){
|
|
||||||
if(text.isEmpty()) return false;
|
|
||||||
QVector<uint> utf32_string = text.toUcs4();
|
|
||||||
for (auto &code : utf32_string)
|
|
||||||
if(codepointIsVisible(code) && !Utils::codepointIsEmoji(code))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString Utils::encodeTextToQmlRichFormat(const QString& text, const QVariantMap& options){
|
|
||||||
//QString images;
|
|
||||||
//QStringList imageFormat;
|
|
||||||
//for(auto format : QImageReader::supportedImageFormats())
|
|
||||||
// imageFormat.append(QString::fromLatin1(format).toUpper());
|
|
||||||
|
|
||||||
QStringList formattedText;
|
|
||||||
bool lastWasUrl = false;
|
|
||||||
|
|
||||||
if(options.contains("noLink") && options["noLink"].toBool()){
|
|
||||||
formattedText.append(encodeEmojiToQmlRichFormat(text));
|
|
||||||
}else{
|
|
||||||
auto primaryColor = App::getInstance()->getColorListModel()->getColor("i")->getColor();
|
|
||||||
auto iriParsed = UriTools::parseIri(text);
|
|
||||||
|
|
||||||
for(int i = 0 ; i < iriParsed.size() ; ++i){
|
|
||||||
QString iri = iriParsed[i].second.replace('&', "&")
|
|
||||||
.replace('<', "\u2063<")
|
|
||||||
.replace('>', "\u2063>")
|
|
||||||
.replace('"', """)
|
|
||||||
.replace('\'', "'");
|
|
||||||
if(!iriParsed[i].first){
|
|
||||||
if(lastWasUrl){
|
|
||||||
lastWasUrl = false;
|
|
||||||
if(iri.front() != ' ')
|
|
||||||
iri.push_front(' ');
|
|
||||||
}
|
|
||||||
formattedText.append(encodeEmojiToQmlRichFormat(iri));
|
|
||||||
}else{
|
|
||||||
QString uri = iriParsed[i].second.left(3) == "www" ? "http://"+iriParsed[i].second : iriParsed[i].second
|
|
||||||
;
|
|
||||||
/* TODO : preview from link
|
|
||||||
//int extIndex = iriParsed[i].second.lastIndexOf('.');
|
|
||||||
//QString ext;
|
|
||||||
//if( extIndex >= 0)
|
|
||||||
// ext = iriParsed[i].second.mid(extIndex+1).toUpper();
|
|
||||||
//if(imageFormat.contains(ext.toLatin1())){// imagesHeight is not used because of bugs on display (blank
|
|
||||||
image if set without width)
|
|
||||||
// images += "<a href=\"" + uri + "\"><img" + (
|
|
||||||
// options.contains("imagesWidth")
|
|
||||||
// ? QString(" width='") + options["imagesWidth"].toString() + "'"
|
|
||||||
// : ""
|
|
||||||
// ) + (
|
|
||||||
// options.contains("imagesWidth")
|
|
||||||
// ? QString(" height='auto'")
|
|
||||||
// : ""
|
|
||||||
// ) + " src=\"" + iriParsed[i].second + "\" />"+uri+"</a>";
|
|
||||||
//}else{
|
|
||||||
formattedText.append( "<a style=\"color:"+ primaryColor.name() +";\" href=\"" + uri + "\">" + iri +
|
|
||||||
"</a>"); lastWasUrl = true;
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(lastWasUrl && formattedText.last().back() != ' '){
|
|
||||||
formattedText.push_back(" ");
|
|
||||||
}
|
|
||||||
return "<p style=\"white-space:pre-wrap;\">" + formattedText.join("") + "</p>";
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Utils::getFileContent(const QString& filePath){
|
|
||||||
QString contents;
|
|
||||||
QFile file(filePath);
|
|
||||||
if (!file.open(QFile::ReadOnly | QFile::Text))
|
|
||||||
return "";
|
|
||||||
return file.readAll();
|
|
||||||
}
|
|
||||||
static QStringList gDbPaths;
|
|
||||||
|
|
||||||
void Utils::deleteAllUserData(){
|
|
||||||
// Store usable data like custom folders
|
|
||||||
gDbPaths.clear();
|
|
||||||
gDbPaths.append(Utils::coreStringToAppString(linphone::Factory::get()->getDataDir(nullptr)));
|
|
||||||
gDbPaths.append(Utils::coreStringToAppString(linphone::Factory::get()->getConfigDir(nullptr)));
|
|
||||||
// Exit with a delete code
|
|
||||||
App::getInstance()->exit(App::DeleteDataCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Utils::deleteAllUserDataOffline(){
|
|
||||||
qWarning() << "Deleting all data! ";
|
|
||||||
for(int i = 0 ; i < gDbPaths.size() ; ++i){
|
|
||||||
QDir dir(gDbPaths[i]);
|
|
||||||
qWarning() << "Deleting " << gDbPaths[i] << " : " << (dir.removeRecursively() ? "Successfully" : "Failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------
|
|
||||||
// WIDGETS
|
|
||||||
//-------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
bool Utils::openWithPdfViewer(ContentModel * contentModel, const QString& filePath, const int& width, const int& height)
|
|
||||||
{ #ifdef PDF_ENABLED PdfWidget *view = new PdfWidget(contentModel); view->setMinimumSize(QSize(width, height));
|
|
||||||
view->show();
|
|
||||||
view->open(filePath);
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Utils::setFamilyFont(QAction * dest, const QString& family){
|
|
||||||
QFont font(dest->font());
|
|
||||||
font.setFamily(family);
|
|
||||||
dest->setFont(font);
|
|
||||||
}
|
|
||||||
void Utils::setFamilyFont(QWidget * dest, const QString& family){
|
|
||||||
QFont font(dest->font());
|
|
||||||
font.setFamily(family);
|
|
||||||
dest->setFont(font);
|
|
||||||
}
|
|
||||||
QPixmap Utils::getMaskedPixmap(const QString& name, const QColor& color){
|
|
||||||
QSize size;
|
|
||||||
QPixmap img = ImageProvider::computePixmap(name, &size);
|
|
||||||
QPixmap pxr( img.size() );
|
|
||||||
pxr.fill( color );
|
|
||||||
pxr.setMask( img.createMaskFromColor( Qt::transparent ) );
|
|
||||||
return pxr;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
|
||||||
|
|
@ -21,18 +21,11 @@
|
||||||
#ifndef UTILS_H_
|
#ifndef UTILS_H_
|
||||||
#define UTILS_H_
|
#define UTILS_H_
|
||||||
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QImage>
|
|
||||||
#include <QLocale>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "Constants.hpp"
|
#include "Constants.hpp"
|
||||||
|
|
||||||
class QAction;
|
|
||||||
class QWidget;
|
|
||||||
class DateModel;
|
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -47,75 +40,12 @@ class DateModel;
|
||||||
#endif // if defined(__GNUC__) && __GNUC__ >= 7
|
#endif // if defined(__GNUC__) && __GNUC__ >= 7
|
||||||
#endif // ifndef UTILS_NO_BREAK
|
#endif // ifndef UTILS_NO_BREAK
|
||||||
|
|
||||||
class ContentModel;
|
|
||||||
|
|
||||||
class Utils : public QObject {
|
class Utils : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Utils(QObject *parent = nullptr) : QObject(parent) {
|
Utils(QObject *parent = nullptr) : QObject(parent) {
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
typedef enum{
|
|
||||||
SIP_DISPLAY_USERNAME = 0,
|
|
||||||
SIP_DISPLAY_ALL = -1
|
|
||||||
}SipDisplayMode;
|
|
||||||
Q_ENUM(SipDisplayMode)
|
|
||||||
|
|
||||||
// Qt interfaces
|
|
||||||
Q_INVOKABLE static bool hasCapability(const QString& address, const LinphoneEnums::FriendCapability& capability,
|
|
||||||
bool defaultCapability = true);
|
|
||||||
// ***** DATE TIME
|
|
||||||
Q_INVOKABLE static QDateTime addMinutes(QDateTime date, const int& min);
|
|
||||||
static QDateTime getOffsettedUTC(const QDateTime& date);
|
|
||||||
Q_INVOKABLE static QString toDateTimeString(QDateTime date, const QString& format = "yyyy/MM/dd hh:mm:ss");
|
|
||||||
Q_INVOKABLE static QString toTimeString(QDateTime date, const QString& format = "hh:mm:ss");
|
|
||||||
Q_INVOKABLE static QString toDateString(QDateTime date, const QString& format = "");
|
|
||||||
Q_INVOKABLE static QString toDateString(QDate date, const QString& format = "");
|
|
||||||
Q_INVOKABLE static QString toDisplayString(const QString& str, SipDisplayMode displayMode = SIP_DISPLAY_ALL);
|
|
||||||
Q_INVOKABLE static QDate getCurrentDate();
|
|
||||||
Q_INVOKABLE static DateModel* getCurrentDateModel();
|
|
||||||
Q_INVOKABLE static QDate getMinDate();
|
|
||||||
Q_INVOKABLE static DateModel* getMinDateModel();
|
|
||||||
Q_INVOKABLE static QDate toDate(const QString& str, const QString& format = "yyyy/MM/dd");
|
|
||||||
Q_INVOKABLE static QDate getDate(int year, int month, int day);
|
|
||||||
Q_INVOKABLE static DateModel* toDateModel(const QString& str, const QString& format = "yyyy/MM/dd");
|
|
||||||
Q_INVOKABLE static DateModel* getDateModel(int year, int month, int day);
|
|
||||||
Q_INVOKABLE static int getFullYear(const QDate& date);
|
|
||||||
Q_INVOKABLE static int getMonth(const QDate& date);
|
|
||||||
Q_INVOKABLE static int getDay(const QDate& date);
|
|
||||||
Q_INVOKABLE static int getDayOfWeek(const QDate& date);
|
|
||||||
Q_INVOKABLE static bool equals(const QDate& d1, const QDate& d2); // Override JS '==' operator
|
|
||||||
Q_INVOKABLE static bool isGreatherThan(const QDate& d1, const QDate& d2); // Override JS '>=' operator
|
|
||||||
//*****
|
|
||||||
static void cleanDisplayNameCache(const QString& address = "");// if "", clean all cache
|
|
||||||
Q_INVOKABLE static QString getDisplayName(const QString& address);
|
|
||||||
Q_INVOKABLE static QString getInitials(const QString& username); // Support UTF32
|
|
||||||
Q_INVOKABLE static QString toString(const LinphoneEnums::TunnelMode& mode);
|
|
||||||
Q_INVOKABLE static bool isMe(const QString& address);
|
|
||||||
Q_INVOKABLE static bool isAnimatedImage(const QString& path);
|
|
||||||
Q_INVOKABLE static bool isImage(const QString& path);
|
|
||||||
Q_INVOKABLE static bool isVideo(const QString& path);
|
|
||||||
Q_INVOKABLE static bool isPdf(const QString& path);
|
|
||||||
Q_INVOKABLE static bool isSupportedForDisplay(const QString& path);
|
|
||||||
Q_INVOKABLE static bool canHaveThumbnail(const QString& path);
|
|
||||||
Q_INVOKABLE static bool isPhoneNumber(const QString& txt);
|
|
||||||
Q_INVOKABLE static bool isUsername(const QString& txt); // Check with Regex
|
|
||||||
Q_INVOKABLE static bool isValidUrl(const QString& url);
|
|
||||||
Q_INVOKABLE QSize getImageSize(const QString& url);
|
|
||||||
Q_INVOKABLE static QPoint getCursorPosition();
|
|
||||||
Q_INVOKABLE static QString getFileChecksum(const QString& filePath);
|
|
||||||
static bool codepointIsEmoji(uint code);
|
|
||||||
static bool codepointIsVisible(uint code);
|
|
||||||
Q_INVOKABLE static bool isOnlyEmojis(const QString& text);
|
|
||||||
Q_INVOKABLE static QString encodeEmojiToQmlRichFormat(const QString &body);
|
|
||||||
Q_INVOKABLE static QString encodeTextToQmlRichFormat(const QString& text, const QVariantMap& options =
|
|
||||||
QVariantMap()); Q_INVOKABLE static QString getFileContent(const QString& filePath);
|
|
||||||
|
|
||||||
Q_INVOKABLE static bool openWithPdfViewer(ContentModel *contentModel, const QString& filePath, const int& width,
|
|
||||||
const int& height); // return true if PDF is enabled
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
static inline QString coreStringToAppString(const std::string &str) {
|
static inline QString coreStringToAppString(const std::string &str) {
|
||||||
if (Constants::LinphoneLocaleEncoding == QString("UTF-8")) return QString::fromStdString(str);
|
if (Constants::LinphoneLocaleEncoding == QString("UTF-8")) return QString::fromStdString(str);
|
||||||
else
|
else
|
||||||
|
|
@ -131,75 +61,10 @@ public:
|
||||||
// Reverse function of strstr.
|
// Reverse function of strstr.
|
||||||
static char *rstrstr(const char *a, const char *b);
|
static char *rstrstr(const char *a, const char *b);
|
||||||
|
|
||||||
/*
|
template <typename T, typename... Args>
|
||||||
// Return the path if it is an image else an empty path.
|
static std::shared_ptr<T> makeQObject_ptr(Args &&...args) {
|
||||||
static QImage getImage(const QString &pUri);
|
return std::shared_ptr<T>(new T(args...), [](T *obj) { obj->deleteLater(); });
|
||||||
// Returns the same path given in parameter if `filePath` exists.
|
|
||||||
// Otherwise returns a safe path with a unique number before the extension.
|
|
||||||
static QString getSafeFilePath (const QString &filePath, bool *soFarSoGood = nullptr);
|
|
||||||
static std::shared_ptr<linphone::Address> getMatchingLocalAddress(std::shared_ptr<linphone::Address>
|
|
||||||
p_localAddress); static QString cleanSipAddress (const QString &sipAddress);// Return at most : sip:username@domain
|
|
||||||
// Test if the process exists
|
|
||||||
static bool processExists(const quint64& p_processId);
|
|
||||||
|
|
||||||
// Connect once to a member function.
|
|
||||||
template<typename Func1, typename Func2>
|
|
||||||
static inline QMetaObject::Connection connectOnce (
|
|
||||||
typename QtPrivate::FunctionPointer<Func1>::Object *sender,
|
|
||||||
Func1 signal,
|
|
||||||
typename QtPrivate::FunctionPointer<Func2>::Object *receiver,
|
|
||||||
Func2 slot
|
|
||||||
) {
|
|
||||||
QMetaObject::Connection connection = QObject::connect(sender, signal, receiver, slot);
|
|
||||||
QMetaObject::Connection *deleter = new QMetaObject::Connection();
|
|
||||||
|
|
||||||
*deleter = QObject::connect(sender, signal, [connection, deleter] {
|
|
||||||
QObject::disconnect(connection);
|
|
||||||
QObject::disconnect(*deleter);
|
|
||||||
delete deleter;
|
|
||||||
});
|
|
||||||
|
|
||||||
return connection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect once to a function.
|
|
||||||
template<typename Func1, typename Func2>
|
|
||||||
static inline QMetaObject::Connection connectOnce (
|
|
||||||
typename QtPrivate::FunctionPointer<Func1>::Object *sender,
|
|
||||||
Func1 signal,
|
|
||||||
const QObject *receiver,
|
|
||||||
Func2 slot
|
|
||||||
) {
|
|
||||||
QMetaObject::Connection connection = QObject::connect(sender, signal, receiver, slot);
|
|
||||||
QMetaObject::Connection *deleter = new QMetaObject::Connection();
|
|
||||||
|
|
||||||
*deleter = QObject::connect(sender, signal, [connection, deleter] {
|
|
||||||
QObject::disconnect(connection);
|
|
||||||
QObject::disconnect(*deleter);
|
|
||||||
delete deleter;
|
|
||||||
});
|
|
||||||
|
|
||||||
return connection;
|
|
||||||
}
|
|
||||||
static std::shared_ptr<linphone::Address> interpretUrl(const QString& address);
|
|
||||||
|
|
||||||
|
|
||||||
static QString getCountryName(const QLocale::Country& country);
|
|
||||||
static void copyDir(QString from, QString to);// Copy a folder recursively without erasing old file
|
|
||||||
static QString getDisplayName(const std::shared_ptr<const linphone::Address>& address); // Get the displayname from
|
|
||||||
addres in this order : Friends, Contact, Display address, Username address static std::shared_ptr<linphone::Config>
|
|
||||||
getConfigIfExists (const QString& configPath); static QString getApplicationProduct(); static QString
|
|
||||||
getOsProduct(); static QString computeUserAgent(const std::shared_ptr<linphone::Config>& config);
|
|
||||||
|
|
||||||
static bool isMe(const std::shared_ptr<const linphone::Address>& address);
|
|
||||||
|
|
||||||
static void deleteAllUserData();
|
|
||||||
static void deleteAllUserDataOffline();// When we are out of all events and core is not running (aka in main())
|
|
||||||
|
|
||||||
static void setFamilyFont(QAction * dest, const QString& family);
|
|
||||||
static void setFamilyFont(QWidget * dest, const QString& family);
|
|
||||||
static QPixmap getMaskedPixmap(const QString& name, const QColor& color);
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UTILS_H_
|
#endif // UTILS_H_
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ list(APPEND _LINPHONEAPP_QML_FILES
|
||||||
view/Page/Login/WelcomePage.qml
|
view/Page/Login/WelcomePage.qml
|
||||||
|
|
||||||
# Prototypes
|
# Prototypes
|
||||||
view/Prototype/PhoneNumberItem.qml
|
view/Prototype/PhoneNumberPrototype.qml
|
||||||
|
view/Prototype/AccountsPrototype.qml
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND _LINPHONEAPP_QML_SINGLETONS
|
list(APPEND _LINPHONEAPP_QML_SINGLETONS
|
||||||
|
|
|
||||||
64
Linphone/view/Prototype/AccountsPrototype.qml
Normal file
64
Linphone/view/Prototype/AccountsPrototype.qml
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Layouts 1.0
|
||||||
|
import QtQuick.Controls as Control
|
||||||
|
import Linphone
|
||||||
|
// Snippet
|
||||||
|
|
||||||
|
ListView{
|
||||||
|
id: mainItem
|
||||||
|
model: AccountProxy{}
|
||||||
|
function printObject(o) {
|
||||||
|
var out = '';
|
||||||
|
for (var p in o) {
|
||||||
|
out += p + ': ' + o[p] + '\n';
|
||||||
|
}
|
||||||
|
if(!o)
|
||||||
|
return 'Empty'
|
||||||
|
else
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: Rectangle{
|
||||||
|
height: 50
|
||||||
|
width: mainItem.width
|
||||||
|
RowLayout{
|
||||||
|
anchors.fill: parent
|
||||||
|
Rectangle{
|
||||||
|
Layout.preferredHeight: 50
|
||||||
|
Layout.preferredWidth: 50
|
||||||
|
//color: '#111111'
|
||||||
|
Image{
|
||||||
|
id: avatar
|
||||||
|
anchors.fill: parent
|
||||||
|
source: $modelData.pictureUri
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text{
|
||||||
|
text: $modelData.identityAddress
|
||||||
|
}
|
||||||
|
Text{
|
||||||
|
text: $modelData.registrationState == LinphoneEnums.RegistrationState.Ok
|
||||||
|
? 'Online'
|
||||||
|
: $modelData.registrationState == LinphoneEnums.RegistrationState.Failed
|
||||||
|
? 'Error'
|
||||||
|
: $modelData.registrationState == LinphoneEnums.RegistrationState.Progress || $modelData.registrationState == LinphoneEnums.RegistrationState.Refreshing
|
||||||
|
? 'Connecting'
|
||||||
|
: 'Offline'
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MouseArea{
|
||||||
|
anchors.fill: parent
|
||||||
|
property int clickCount : 0
|
||||||
|
onClicked: {
|
||||||
|
if(++clickCount % 2 == 0)
|
||||||
|
$modelData.pictureUri = AppIcons.loginImage;
|
||||||
|
else
|
||||||
|
$modelData.pictureUri = AppIcons.eyeShow;
|
||||||
|
console.log(printObject($modelData))
|
||||||
|
console.debug("[ProtoAccounts] Account Select: " +$modelData.contactAddress +" / "+$modelData.identityAddress + " / " +$modelData.pictureUri + " / " +$modelData.registrationState)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in a new issue