From a7d6555de232aebc790be343b79919b08220a85e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Thu, 30 Jan 2020 21:01:23 +0100 Subject: [PATCH] Make sure that the libcloudprovider integration is using a valid D-Bus path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set a simple unique identifier per folder to ensure that it is always unique. Fixes https://github.com/nextcloud/desktop/issues/1704 Signed-off-by: Corentin Noël --- src/gui/cloudproviders/cloudprovidermanager.cpp | 6 +++--- src/gui/cloudproviders/cloudprovidermanager.h | 1 + src/gui/cloudproviders/cloudproviderwrapper.cpp | 4 ++-- src/gui/cloudproviders/cloudproviderwrapper.h | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gui/cloudproviders/cloudprovidermanager.cpp b/src/gui/cloudproviders/cloudprovidermanager.cpp index eaf2f2cb5..892f60abd 100644 --- a/src/gui/cloudproviders/cloudprovidermanager.cpp +++ b/src/gui/cloudproviders/cloudprovidermanager.cpp @@ -52,8 +52,8 @@ void CloudProviderManager::registerSignals() CloudProviderManager::CloudProviderManager(QObject *parent) : QObject(parent) { _map = new QMap(); - QString busName = QString(LIBCLOUDPROVIDERS_DBUS_BUS_NAME); - g_bus_own_name (G_BUS_TYPE_SESSION, busName.toAscii().data(), G_BUS_NAME_OWNER_FLAGS_NONE, nullptr, on_name_acquired, nullptr, this, nullptr); + _folder_index = 0; + g_bus_own_name (G_BUS_TYPE_SESSION, LIBCLOUDPROVIDERS_DBUS_BUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, nullptr, on_name_acquired, nullptr, this, nullptr); } void CloudProviderManager::slotFolderListChanged(const Folder::Map &folderMap) @@ -72,7 +72,7 @@ void CloudProviderManager::slotFolderListChanged(const Folder::Map &folderMap) while (j.hasNext()) { j.next(); if (!_map->contains(j.key())) { - auto *cpo = new CloudProviderWrapper(this, j.value(), _providerExporter); + auto *cpo = new CloudProviderWrapper(this, j.value(), _folder_index++, _providerExporter); _map->insert(j.key(), cpo); } } diff --git a/src/gui/cloudproviders/cloudprovidermanager.h b/src/gui/cloudproviders/cloudprovidermanager.h index f37d1f0b4..17aafc5dc 100644 --- a/src/gui/cloudproviders/cloudprovidermanager.h +++ b/src/gui/cloudproviders/cloudprovidermanager.h @@ -36,6 +36,7 @@ public slots: private: QMap *_map; + unsigned int _folder_index; }; #endif // CLOUDPROVIDERMANAGER_H diff --git a/src/gui/cloudproviders/cloudproviderwrapper.cpp b/src/gui/cloudproviders/cloudproviderwrapper.cpp index 62118409e..f4e2a7606 100644 --- a/src/gui/cloudproviders/cloudproviderwrapper.cpp +++ b/src/gui/cloudproviders/cloudproviderwrapper.cpp @@ -33,13 +33,13 @@ using namespace OCC; GSimpleActionGroup *actionGroup = nullptr; -CloudProviderWrapper::CloudProviderWrapper(QObject *parent, Folder *folder, CloudProvidersProviderExporter* cloudprovider) : QObject(parent) +CloudProviderWrapper::CloudProviderWrapper(QObject *parent, Folder *folder, int folderId, CloudProvidersProviderExporter* cloudprovider) : QObject(parent) , _folder(folder) { GMenuModel *model; GActionGroup *action_group; _recentlyChanged = new QList>(); - QString accountName = QString("Account%1Folder%2").arg(folder->alias(), folder->accountState()->account()->id()); + QString accountName = QString("Folder/%1").arg(folderId); _cloudProvider = CLOUD_PROVIDERS_PROVIDER_EXPORTER(cloudprovider); _cloudProviderAccount = cloud_providers_account_exporter_new(_cloudProvider, accountName.toUtf8().data()); diff --git a/src/gui/cloudproviders/cloudproviderwrapper.h b/src/gui/cloudproviders/cloudproviderwrapper.h index b1ffc9c9f..24830c89a 100644 --- a/src/gui/cloudproviders/cloudproviderwrapper.h +++ b/src/gui/cloudproviders/cloudproviderwrapper.h @@ -38,7 +38,7 @@ class CloudProviderWrapper : public QObject { Q_OBJECT public: - explicit CloudProviderWrapper(QObject *parent = nullptr, Folder *folder = nullptr, CloudProvidersProviderExporter* cloudprovider = nullptr); + explicit CloudProviderWrapper(QObject *parent = nullptr, Folder *folder = nullptr, int folderId = 0, CloudProvidersProviderExporter* cloudprovider = nullptr); ~CloudProviderWrapper(); CloudProvidersAccountExporter* accountExporter(); Folder* folder();