diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-04-17 15:01:51 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-04-17 15:01:51 +0200 |
commit | bf75a2b6b184a3504cdee4b88a6db4a82c6da150 (patch) | |
tree | 841434e105e89e6a5ef1b6bbe3c1b43a5dd2e499 /common/resourceaccess.cpp | |
parent | c3040251dd4d9e8d00cbccdeb693b11a72077c73 (diff) | |
download | sink-bf75a2b6b184a3504cdee4b88a6db4a82c6da150.tar.gz sink-bf75a2b6b184a3504cdee4b88a6db4a82c6da150.zip |
Don't encode the resource type into the identifier
Diffstat (limited to 'common/resourceaccess.cpp')
-rw-r--r-- | common/resourceaccess.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index c8c8189..33820af 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp | |||
@@ -199,7 +199,7 @@ KAsync::Job<void> ResourceAccess::Private::initializeSocket() | |||
199 | TracePrivate() << "Failed to connect, starting resource"; | 199 | TracePrivate() << "Failed to connect, starting resource"; |
200 | // We failed to connect, so let's start the resource | 200 | // We failed to connect, so let's start the resource |
201 | QStringList args; | 201 | QStringList args; |
202 | args << resourceInstanceIdentifier; | 202 | args << resourceInstanceIdentifier << resourceName; |
203 | qint64 pid = 0; | 203 | qint64 pid = 0; |
204 | if (QProcess::startDetached("sink_synchronizer", args, QDir::homePath(), &pid)) { | 204 | if (QProcess::startDetached("sink_synchronizer", args, QDir::homePath(), &pid)) { |
205 | TracePrivate() << "Started resource " << pid; | 205 | TracePrivate() << "Started resource " << pid; |
@@ -218,15 +218,8 @@ KAsync::Job<void> ResourceAccess::Private::initializeSocket() | |||
218 | }); | 218 | }); |
219 | } | 219 | } |
220 | 220 | ||
221 | static QByteArray getResourceName(const QByteArray &instanceIdentifier) | 221 | ResourceAccess::ResourceAccess(const QByteArray &resourceInstanceIdentifier, const QByteArray &resourceType) |
222 | { | 222 | : ResourceAccessInterface(), d(new Private(resourceType, resourceInstanceIdentifier, this)) |
223 | auto split = instanceIdentifier.split('.'); | ||
224 | split.removeLast(); | ||
225 | return split.join('.'); | ||
226 | } | ||
227 | |||
228 | ResourceAccess::ResourceAccess(const QByteArray &resourceInstanceIdentifier) | ||
229 | : ResourceAccessInterface(), d(new Private(getResourceName(resourceInstanceIdentifier), resourceInstanceIdentifier, this)) | ||
230 | { | 223 | { |
231 | Log() << "Starting access"; | 224 | Log() << "Starting access"; |
232 | } | 225 | } |
@@ -593,7 +586,7 @@ ResourceAccessFactory &ResourceAccessFactory::instance() | |||
593 | return *instance; | 586 | return *instance; |
594 | } | 587 | } |
595 | 588 | ||
596 | Sink::ResourceAccess::Ptr ResourceAccessFactory::getAccess(const QByteArray &instanceIdentifier) | 589 | Sink::ResourceAccess::Ptr ResourceAccessFactory::getAccess(const QByteArray &instanceIdentifier, const QByteArray resourceType) |
597 | { | 590 | { |
598 | if (!mCache.contains(instanceIdentifier)) { | 591 | if (!mCache.contains(instanceIdentifier)) { |
599 | // Reuse the pointer if something else kept the resourceaccess alive | 592 | // Reuse the pointer if something else kept the resourceaccess alive |
@@ -605,7 +598,7 @@ Sink::ResourceAccess::Ptr ResourceAccessFactory::getAccess(const QByteArray &ins | |||
605 | } | 598 | } |
606 | if (!mCache.contains(instanceIdentifier)) { | 599 | if (!mCache.contains(instanceIdentifier)) { |
607 | // Create a new instance if necessary | 600 | // Create a new instance if necessary |
608 | auto sharedPointer = Sink::ResourceAccess::Ptr::create(instanceIdentifier); | 601 | auto sharedPointer = Sink::ResourceAccess::Ptr::create(instanceIdentifier, resourceType); |
609 | QObject::connect(sharedPointer.data(), &Sink::ResourceAccess::ready, sharedPointer.data(), [this, instanceIdentifier](bool ready) { | 602 | QObject::connect(sharedPointer.data(), &Sink::ResourceAccess::ready, sharedPointer.data(), [this, instanceIdentifier](bool ready) { |
610 | if (!ready) { | 603 | if (!ready) { |
611 | mCache.remove(instanceIdentifier); | 604 | mCache.remove(instanceIdentifier); |