Skip to content

Commit

Permalink
Disable IPC proxies when not used
Browse files Browse the repository at this point in the history
  • Loading branch information
Radoslaw Buczkowski authored and jacky309 committed Apr 29, 2020
1 parent c8817ad commit 20b6966
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/ipc/ipc-common/IPCProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,19 @@ class IPCProxy : public WrapperType, public IPCProxyNewBase
{
QObject::connect(ipc(), &IPCProxyBinderBase::complete, this, [this] () {
m_localProviderBinder.init();
auto serviceName = ipc()->serviceName();
auto objPath = ipc()->objectPath();
for (auto& proxy : m_ipcProxies) {
auto proxyAdapterIPCBinder = proxy.ipcBinder;
if (proxyAdapterIPCBinder != nullptr) {
proxyAdapterIPCBinder->setObjectPath(objPath);
if(!serviceName.isEmpty()) {
proxyAdapterIPCBinder->setServiceName(serviceName);
if (m_localProviderBinder.provider() == nullptr) {
auto serviceName = ipc()->serviceName();
auto objPath = ipc()->objectPath();
for (auto& proxy : m_ipcProxies) {
auto proxyAdapterIPCBinder = proxy.ipcBinder;
if (proxyAdapterIPCBinder != nullptr) {
proxyAdapterIPCBinder->setObjectPath(objPath);
if(!serviceName.isEmpty()) {
proxyAdapterIPCBinder->setServiceName(serviceName);
}
proxyAdapterIPCBinder->connectToServer();
QObject::connect(proxyAdapterIPCBinder, &IPCProxyBinderBase::serviceAvailableChanged, this, &IPCProxy::refreshProvider);
}
proxyAdapterIPCBinder->connectToServer();
QObject::connect(proxyAdapterIPCBinder, &IPCProxyBinderBase::serviceAvailableChanged, this, &IPCProxy::refreshProvider);
}
}
this->refreshProvider();
Expand All @@ -85,11 +87,18 @@ class IPCProxy : public WrapperType, public IPCProxyNewBase
InterfaceType *provider = m_defaultProvider;
if (m_localProviderBinder.provider() != nullptr) {
provider = m_localProviderBinder.provider();
for (auto& proxy : m_ipcProxies) {
auto ipcBinder = proxy.ipcBinder;
if (ipcBinder != nullptr) {
ipcBinder->setEnabled(false);
}
}
} else {
for (auto& proxy : m_ipcProxies) {
auto proxyAdapterIPCBinder = proxy.ipcBinder;
if ((proxyAdapterIPCBinder != nullptr) && proxyAdapterIPCBinder->isServiceAvailable()) {
auto ipcBinder = proxy.ipcBinder;
if ((ipcBinder != nullptr) && ipcBinder->isServiceAvailable()) {
provider = proxy.proxy;
ipcBinder->setEnabled(true);
break;
}
}
Expand Down

0 comments on commit 20b6966

Please sign in to comment.