mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
Add moveToThread on Gui objects constructor.
Fix VariantObject connections. Rename call creator API. Update SDK.
This commit is contained in:
parent
cd82964b23
commit
9ec84bb168
13 changed files with 50 additions and 27 deletions
|
|
@ -24,10 +24,10 @@
|
|||
DEFINE_ABSTRACT_OBJECT(AccountGui)
|
||||
|
||||
AccountGui::AccountGui(QSharedPointer<AccountCore> core) {
|
||||
mustBeInMainThread(getClassName());
|
||||
qDebug() << "[AccountGui] new" << this;
|
||||
App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::JavaScriptOwnership);
|
||||
mCore = core;
|
||||
if (isInLinphoneThread()) moveToThread(App::getInstance()->thread());
|
||||
}
|
||||
|
||||
AccountGui::~AccountGui() {
|
||||
|
|
|
|||
|
|
@ -54,18 +54,19 @@ void AccountList::setSelf(QSharedPointer<AccountList> me) {
|
|||
&QObject::deleteLater);
|
||||
mModelConnection->makeConnect(this, &AccountList::lUpdate, [this]() {
|
||||
mModelConnection->invokeToModel([this]() {
|
||||
QList<QSharedPointer<AccountCore>> accounts;
|
||||
QList<QSharedPointer<AccountCore>> *accounts = new QList<QSharedPointer<AccountCore>>();
|
||||
// Model thread.
|
||||
mustBeInLinphoneThread(getClassName());
|
||||
auto linphoneAccounts = CoreModel::getInstance()->getCore()->getAccountList();
|
||||
for (auto it : linphoneAccounts) {
|
||||
auto model = AccountCore::create(it);
|
||||
accounts.push_back(model);
|
||||
accounts->push_back(model);
|
||||
}
|
||||
mModelConnection->invokeToCore([this, accounts]() {
|
||||
mustBeInMainThread(getClassName());
|
||||
clearData();
|
||||
add(accounts);
|
||||
resetData();
|
||||
add(*accounts);
|
||||
delete accounts;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@
|
|||
DEFINE_ABSTRACT_OBJECT(CallGui)
|
||||
|
||||
CallGui::CallGui(QSharedPointer<CallCore> core) {
|
||||
mustBeInMainThread(getClassName());
|
||||
qDebug() << "[CallGui] new" << this;
|
||||
App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::JavaScriptOwnership);
|
||||
mCore = core;
|
||||
if (isInLinphoneThread()) moveToThread(App::getInstance()->thread());
|
||||
}
|
||||
|
||||
CallGui::~CallGui() {
|
||||
|
|
|
|||
|
|
@ -37,8 +37,15 @@ VariantObject::VariantObject(QVariant defaultValue, QObject *parent) {
|
|||
new SafeConnection(mCoreObject.objectCast<QObject>(), mModelObject.objectCast<QObject>()),
|
||||
&QObject::deleteLater);
|
||||
|
||||
mConnection->makeConnect(mCoreObject.get(), &SafeObject::setValue, &SafeObject::onSetValue);
|
||||
mConnection->makeConnect(mModelObject.get(), &SafeObject::setValue, &SafeObject::onSetValue);
|
||||
mConnection->makeConnect(mCoreObject.get(), &SafeObject::setValue, [this](QVariant value) {
|
||||
mConnection->invokeToModel([this, value]() { mModelObject->onSetValue(value); });
|
||||
});
|
||||
mConnection->makeConnect(mModelObject.get(), &SafeObject::setValue, [this](QVariant value) {
|
||||
mConnection->invokeToCore([this, value]() { mCoreObject->onSetValue(value); });
|
||||
});
|
||||
mConnection->makeConnect(mModelObject.get(), &SafeObject::valueChanged, [this](QVariant value) {
|
||||
mConnection->invokeToCore([this, value]() { mCoreObject->valueChanged(value); });
|
||||
});
|
||||
connect(mCoreObject.get(), &SafeObject::valueChanged, this, &VariantObject::valueChanged);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ QString ToolModel::getDisplayName(QString address) {
|
|||
return displayName.isEmpty() ? address : displayName;
|
||||
}
|
||||
|
||||
QSharedPointer<CallCore> ToolModel::startAudioCall(const QString &sipAddress,
|
||||
const QString &prepareTransfertAddress,
|
||||
const QHash<QString, QString> &headers) {
|
||||
QSharedPointer<CallCore> ToolModel::createCall(const QString &sipAddress,
|
||||
const QString &prepareTransfertAddress,
|
||||
const QHash<QString, QString> &headers) {
|
||||
bool waitRegistrationForCall = true; // getSettingsModel()->getWaitRegistrationForCall()
|
||||
std::shared_ptr<linphone::Core> core = CoreModel::getInstance()->getCore();
|
||||
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ public:
|
|||
static QString getDisplayName(const std::shared_ptr<const linphone::Address> &address);
|
||||
static QString getDisplayName(QString address);
|
||||
|
||||
static QSharedPointer<CallCore> startAudioCall(const QString &sipAddress,
|
||||
const QString &prepareTransfertAddress = "",
|
||||
const QHash<QString, QString> &headers = {});
|
||||
static QSharedPointer<CallCore> createCall(const QString &sipAddress,
|
||||
const QString &prepareTransfertAddress = "",
|
||||
const QHash<QString, QString> &headers = {});
|
||||
|
||||
private:
|
||||
DECLARE_ABSTRACT_OBJECT
|
||||
|
|
|
|||
|
|
@ -41,7 +41,9 @@ public:
|
|||
inline QString log() const {
|
||||
return QStringLiteral("[%1]: %2").arg(getClassName()).arg("%1");
|
||||
}
|
||||
|
||||
inline static bool isInLinphoneThread() {
|
||||
return Thread::isInLinphoneThread();
|
||||
}
|
||||
inline static bool mustBeInLinphoneThread(const QString &context) { // For convenience : Alias to Thread
|
||||
return Thread::mustBeInLinphoneThread(context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,13 +50,13 @@ VariantObject *Utils::getDisplayName(const QString &address) {
|
|||
return data;
|
||||
}
|
||||
|
||||
VariantObject *Utils::startAudioCall(const QString &sipAddress,
|
||||
const QString &prepareTransfertAddress,
|
||||
const QHash<QString, QString> &headers) {
|
||||
VariantObject *Utils::createCall(const QString &sipAddress,
|
||||
const QString &prepareTransfertAddress,
|
||||
const QHash<QString, QString> &headers) {
|
||||
VariantObject *data = new VariantObject(QVariant()); // Scope : GUI
|
||||
|
||||
data->makeRequest([sipAddress, prepareTransfertAddress, headers]() {
|
||||
auto call = ToolModel::startAudioCall(sipAddress, prepareTransfertAddress, headers);
|
||||
auto call = ToolModel::createCall(sipAddress, prepareTransfertAddress, headers);
|
||||
if (call) {
|
||||
return QVariant::fromValue(new CallGui(call));
|
||||
} else return QVariant();
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ public:
|
|||
}
|
||||
|
||||
Q_INVOKABLE static VariantObject *getDisplayName(const QString &address);
|
||||
Q_INVOKABLE static VariantObject *startAudioCall(const QString &sipAddress,
|
||||
const QString &prepareTransfertAddress = "",
|
||||
const QHash<QString, QString> &headers = {});
|
||||
Q_INVOKABLE static VariantObject *createCall(const QString &sipAddress,
|
||||
const QString &prepareTransfertAddress = "",
|
||||
const QHash<QString, QString> &headers = {});
|
||||
Q_INVOKABLE static VariantObject *haveAccount();
|
||||
|
||||
static inline QString coreStringToAppString(const std::string &str) {
|
||||
|
|
|
|||
|
|
@ -33,12 +33,16 @@ void Thread::run() {
|
|||
if (result <= 0) toExit = true;
|
||||
}
|
||||
}
|
||||
bool Thread::isInLinphoneThread() {
|
||||
return QThread::currentThread() == CoreModel::getInstance()->thread();
|
||||
}
|
||||
|
||||
bool Thread::mustBeInLinphoneThread(const QString &context) {
|
||||
bool isLinphoneThread = QThread::currentThread() == CoreModel::getInstance()->thread();
|
||||
bool isLinphoneThread = isInLinphoneThread();
|
||||
if (!isLinphoneThread) qCritical() << "[Thread] Not processing in Linphone thread from " << context;
|
||||
return isLinphoneThread;
|
||||
}
|
||||
|
||||
bool Thread::mustBeInMainThread(const QString &context) {
|
||||
bool isMainThread = QThread::currentThread() == App::getInstance()->thread();
|
||||
if (!isMainThread) qCritical() << "[Thread] Not processing in Main thread from " << context;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
class Thread : public QThread {
|
||||
public:
|
||||
Thread(QObject *parent = nullptr);
|
||||
static bool isInLinphoneThread();
|
||||
static bool mustBeInLinphoneThread(const QString &context);
|
||||
static bool mustBeInMainThread(const QString &context);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ Window{
|
|||
gc()
|
||||
}
|
||||
Component.onDestruction: gc()
|
||||
Connections{
|
||||
target: call && call.core || null
|
||||
onLastErrorMessageChanged: if(mainItem.call) errorMessageText.text=mainItem.call.core.lastErrorMessage
|
||||
}
|
||||
ColumnLayout{
|
||||
anchors.fill: parent
|
||||
RowLayout {
|
||||
|
|
@ -69,8 +73,11 @@ Window{
|
|||
id: accountStatus
|
||||
Layout.preferredWidth: 50
|
||||
Layout.preferredHeight: 50
|
||||
property int accountCount: accountProxy.count
|
||||
onAccountCountChanged: console.log("AccountCount:"+accountCount)
|
||||
property var defaultAccount: accountProxy.defaultAccount
|
||||
property var state: accountProxy.count > 0 && defaultAccount? defaultAccount.registrationState : LoginPageCpp.registrationState
|
||||
onDefaultAccountChanged: console.log("DefaultAccount:"+defaultAccount)
|
||||
property var state: accountProxy.count > 0 && defaultAccount? defaultAccount.core.registrationState : LoginPageCpp.registrationState
|
||||
onStateChanged: console.log("State:"+state)
|
||||
|
||||
color: state === LinphoneEnums.RegistrationState.Ok
|
||||
|
|
@ -94,7 +101,9 @@ Window{
|
|||
Button{
|
||||
text: 'Call'
|
||||
onClicked: {
|
||||
mainItem.callVarObject = UtilsCpp.startAudioCall(usernameToCall.inputText + "@sip.linphone.org")
|
||||
var address = usernameToCall.text + "@sip.linphone.org"
|
||||
console.log("Calling "+address)
|
||||
mainItem.callVarObject = UtilsCpp.createCall(address)
|
||||
proto.component1 = comp
|
||||
}
|
||||
}
|
||||
|
|
@ -123,7 +132,6 @@ Window{
|
|||
}
|
||||
Text{
|
||||
id: errorMessageText
|
||||
text: mainItem.call ? mainItem.call.core.lastErrorMessage : ''
|
||||
color: 'red'
|
||||
}
|
||||
ItemPrototype{
|
||||
|
|
|
|||
2
external/linphone-sdk
vendored
2
external/linphone-sdk
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit aaeaad94a6e63f182f50318ed1a209c83b152d73
|
||||
Subproject commit a9a7ff8bb52d7535033b0cb60e2113b9ee377664
|
||||
Loading…
Add table
Reference in a new issue