mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-28 17:29:19 +00:00
fix(SingleApplication): use modern Qt / C++
This commit is contained in:
parent
4beb9ecf7a
commit
c38b164bf7
4 changed files with 20 additions and 18 deletions
|
|
@ -330,34 +330,34 @@ void SingleApplicationPrivate::slotConnectionEstablished () {
|
|||
}
|
||||
|
||||
QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose, this, [nextConnSocket, instanceId, this]() {
|
||||
Q_EMIT this->slotClientConnectionClosed(nextConnSocket, instanceId);
|
||||
});
|
||||
emit this->slotClientConnectionClosed(nextConnSocket, instanceId);
|
||||
});
|
||||
|
||||
QObject::connect(nextConnSocket, &QLocalSocket::readyRead, this, [nextConnSocket, instanceId, this]() {
|
||||
Q_EMIT this->slotDataAvailable(nextConnSocket, instanceId);
|
||||
});
|
||||
emit this->slotDataAvailable(nextConnSocket, instanceId);
|
||||
});
|
||||
|
||||
if (connectionType == NewInstance || (
|
||||
connectionType == SecondaryInstance &&
|
||||
options & SingleApplication::Mode::SecondaryNotification
|
||||
)
|
||||
) {
|
||||
Q_EMIT q->instanceStarted();
|
||||
emit q->instanceStarted();
|
||||
}
|
||||
|
||||
if (nextConnSocket->bytesAvailable() > 0) {
|
||||
Q_EMIT this->slotDataAvailable(nextConnSocket, instanceId);
|
||||
emit this->slotDataAvailable(nextConnSocket, instanceId);
|
||||
}
|
||||
}
|
||||
|
||||
void SingleApplicationPrivate::slotDataAvailable (QLocalSocket *dataSocket, quint32 instanceId) {
|
||||
Q_Q(SingleApplication);
|
||||
Q_EMIT q->receivedMessage(instanceId, dataSocket->readAll());
|
||||
emit q->receivedMessage(instanceId, dataSocket->readAll());
|
||||
}
|
||||
|
||||
void SingleApplicationPrivate::slotClientConnectionClosed (QLocalSocket *closedSocket, quint32 instanceId) {
|
||||
if (closedSocket->bytesAvailable() > 0)
|
||||
Q_EMIT slotDataAvailable(closedSocket, instanceId);
|
||||
emit slotDataAvailable(closedSocket, instanceId);
|
||||
closedSocket->deleteLater();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class SingleApplicationPrivate;
|
|||
* @see QCoreApplication
|
||||
*/
|
||||
class SingleApplication : public QApplication {
|
||||
Q_OBJECT
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
/**
|
||||
|
|
@ -114,7 +114,7 @@ public:
|
|||
|
||||
virtual void quit ();
|
||||
|
||||
Q_SIGNALS:
|
||||
signals:
|
||||
void instanceStarted ();
|
||||
void receivedMessage (quint32 instanceId, QByteArray message);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,9 @@
|
|||
|
||||
// =============================================================================
|
||||
|
||||
const char *SERVICE_NAME = "org.linphone.SingleApplication";
|
||||
namespace {
|
||||
constexpr char ServiceName[] = "org.linphone.SingleApplication";
|
||||
}
|
||||
|
||||
SingleApplicationPrivate::SingleApplicationPrivate (SingleApplication *q_ptr)
|
||||
: QDBusAbstractAdaptor(q_ptr), q_ptr(q_ptr) {}
|
||||
|
|
@ -66,7 +68,7 @@ SingleApplication::SingleApplication (int &argc, char *argv[], bool allowSeconda
|
|||
::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (d->getBus().registerService(SERVICE_NAME)) {
|
||||
if (d->getBus().registerService(ServiceName)) {
|
||||
d->startPrimary();
|
||||
return;
|
||||
}
|
||||
|
|
@ -105,19 +107,19 @@ bool SingleApplication::sendMessage (QByteArray message, int timeout) {
|
|||
|
||||
if (isPrimary()) return false;
|
||||
|
||||
QDBusInterface iface(SERVICE_NAME, "/", "", d->getBus());
|
||||
QDBusInterface iface(ServiceName, "/", "", d->getBus());
|
||||
if (iface.isValid()) {
|
||||
iface.setTimeout(timeout);
|
||||
QDBusMessage msg = iface.call(QDBus::Block, "messageReceived", instanceId(), message);
|
||||
QDBusMessage msg = iface.call(QDBus::Block, "handleMessageReceived", instanceId(), message);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void SingleApplicationPrivate::messageReceived (quint32 instanceId, QByteArray message) {
|
||||
void SingleApplicationPrivate::handleMessageReceived (quint32 instanceId, QByteArray message) {
|
||||
Q_Q(SingleApplication);
|
||||
Q_EMIT q->receivedMessage(instanceId, message);
|
||||
emit q->receivedMessage(instanceId, message);
|
||||
}
|
||||
|
||||
void SingleApplication::quit () {
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ public:
|
|||
SingleApplication::Options options;
|
||||
quint32 instanceNumber;
|
||||
|
||||
public Q_SLOTS:
|
||||
void messageReceived (quint32 instanceId, QByteArray message);
|
||||
private:
|
||||
void handleMessageReceived (quint32 instanceId, QByteArray message);
|
||||
};
|
||||
|
||||
#endif // SINGLE_APPLICATION_DBUS_PRIVATE_H_
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue