From 84875396b75f5615afa637f9633d19bbc79e08e0 Mon Sep 17 00:00:00 2001 From: kh1 Date: Tue, 14 Oct 2014 17:03:54 +0200 Subject: Overhaul the binary format API. Adjust some naming. Add documentation. Make the Resource class handle files only, this is sufficient to read and map inbuild resources. Keep the QResources inside the manager as well, no need to handle them separate. Remove read, write functions from collection class, the API was just unclear how to use. Still it is far from intuitive in the manager class either. If we open a Resource, we need to close it on our own case they are pointers. Change-Id: Ic8aa32a84a15ac774fe1194ba0dbb5733f7216d6 Reviewed-by: Leena Miettinen Reviewed-by: Kai Koehne --- src/sdk/sdkapp.h | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) (limited to 'src/sdk/sdkapp.h') diff --git a/src/sdk/sdkapp.h b/src/sdk/sdkapp.h index a00e2d0e8..d6f830b37 100644 --- a/src/sdk/sdkapp.h +++ b/src/sdk/sdkapp.h @@ -48,7 +48,6 @@ #include #include -#include #include #include #include @@ -64,12 +63,8 @@ public: virtual ~SDKApp() { - using namespace QInstaller; - foreach (const QSharedPointer &resource, resourceMappings.resources()) { - resource->open(); // ignore error here, either we opened it or it is opened - QResource::unregisterResource((const uchar *) resource->readAll().constData(), - QLatin1String(":/metadata")); - } + foreach (const QByteArray &ba, m_resourceMappings) + QResource::unregisterResource((const uchar*) ba.data(), QLatin1String(":/metadata")); } bool notify(QObject *receiver, QEvent *event) @@ -132,14 +127,9 @@ public: return QString(); } - QInstaller::ResourceCollection registeredMetaResources() - { - return resourceMappings; - } - - void registerMetaResources(const QInstaller::ResourceCollection &resources) + void registerMetaResources(const QInstaller::ResourceCollection &collection) { - foreach (const QSharedPointer &resource, resources.resources()) { + foreach (const QSharedPointer &resource, collection.resources()) { const bool isOpen = resource->isOpen(); if ((!isOpen) && (!resource->open())) continue; @@ -151,20 +141,16 @@ public: if (ba.isEmpty()) continue; - if (QResource::registerResource((const uchar*) ba.data(), QLatin1String(":/metadata"))) { - using namespace QInstaller; - QSharedPointer buffer(new QBuffer); - buffer->setData(ba); // set the buffers internal data - resourceMappings.appendResource(QSharedPointer(new Resource(buffer))); - } + if (QResource::registerResource((const uchar*) ba.data(), QLatin1String(":/metadata"))) + m_resourceMappings.append(ba); - if (!isOpen) // If we reach that point, either the resource was opened already... - resource->close(); // or we did open it and have to close it again. + if (!isOpen) // If we reach that point, either the resource was opened already... + resource->close(); // or we did open it and have to close it again. } } private: - QInstaller::ResourceCollection resourceMappings; + QList m_resourceMappings; }; #endif // SDKAPP_H -- cgit v1.2.3