diff -r 1a2a00e78665 -r 7feec50967db contentstorage/caclient/stub/src/hswidgetregistryservice.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contentstorage/caclient/stub/src/hswidgetregistryservice.cpp Tue Mar 23 23:17:02 2010 +0200 @@ -0,0 +1,349 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Manages installed widgets information +* +*/ + +#include +#include +#include + +#include "hswidgetregistryservice.h" +#include "hswidgetregistryservice_p.h" +#include "hswidgetprovidermanifest.h" +#include "servicefinder.h" + +const char POSTERURI[] = "homescreen.nokia.com/widget/poster/"; +const char POSTERWIDGETNAME[] = "name"; +const char POSTERWIDGETID[] = "posterwidgetid"; +const char PUBLISHER[] = "publisher"; +const char TEMPLATETYPE[] = "templatetype"; +const char CONTENTID[] = "contentid"; +const char CONTENTTYPE[] = "contenttype"; + +/*! + ?Qt_style_documentation +*/ +HsWidgetRegistryServicePrivate::HsWidgetRegistryServicePrivate( + const QString& installationPath, HsWidgetRegistryService* ptrToPublic, + QObject* parent) : QObject(parent) +{ + Q_UNUSED(ptrToPublic); + QStringList manifestPaths; + + this->mInstallationPath = installationPath; + QDir currentDir = QDir::current(); + QString currentPath = currentDir.absolutePath(); + + //Check widget installation dirs from root of different drives + QFileInfoList drives = QDir::drives(); + + // ? + for(int i=0; i < drives.count(); i++) { + QFileInfo drive = drives.at(i); + QString driveLetter = drive.absolutePath(); + QString path = currentPath + "/" + mInstallationPath; + QDir registryDir(path); + + if(registryDir.exists()) { + // ? + mManifestDirectories[path] = readManifestDirectories(path); + } + } +} + +/*! + ?Qt_style_documentation +*/ +HsWidgetRegistryServicePrivate::~HsWidgetRegistryServicePrivate() +{ + +} + +/*! + ?Qt_style_documentation +*/ +QList HsWidgetRegistryServicePrivate::widgets() { + QList widgets; + QMapIterator i(mManifestDirectories); + + while (i.hasNext()) { + i.next(); + QStringList manifestFileList = i.value(); + QDir manifestDir(i.key()); + + // ? + for(int h=0; h < manifestFileList.count(); h++) { + widgets << readManifestFile(manifestDir.absoluteFilePath(manifestFileList.at(h))); + } + } + return widgets; +} + +/*! + ?Qt_style_documentation +*/ +IHsWidgetProvider* HsWidgetRegistryServicePrivate::loadProviderFromPlugin( + const QString& pluginName) +{ + QPluginLoader loader(pluginName); + QObject *plugin = loader.instance(); + IHsWidgetProvider *provider = qobject_cast(plugin); + + if (provider) { + // ? + return provider; + } + + // Don't leak memory if provider not IHsWidgetProvider + if (plugin) { + //qDebug("Widget provider load - !provider, deleting plugin.") + delete plugin; + } + + // qDebug("Widget provider load failed - Not found.") + return 0; +} + +/*! + ?Qt_style_documentation +*/ +QStringList HsWidgetRegistryServicePrivate::readManifestDirectories(const QString &path) +{ + QStringList widgetDirPaths; + QDir registryDir(path); + QStringList widgetDirs = registryDir.entryList(QDir::AllDirs); + + // ? + for (int i=0; i < widgetDirs.count(); ++i) { + widgetDirPaths << registryDir.absoluteFilePath(widgetDirs.at(i)); + } + return widgetDirPaths; +} + +/*! + ?Qt_style_documentation +*/ +void HsWidgetRegistryServicePrivate::doWidgetRemove(const QString &path, + const QStringList &originalList, const QStringList ¤tList) +{ + Q_UNUSED(path); + const int originalCount = originalList.count(); + + // ? + for (int i=0; iemitWidgetRemovedFromRegistry(widgetUid); + } + } +} + +/*! + ?Qt_style_documentation +*/ +QList HsWidgetRegistryServicePrivate::readManifestFile( + const QString &manifestFilePath) +{ + QList widgets; + HsWidgetProviderManifest manifest; + QStringList filters("*.manifest"); + QDir dir(manifestFilePath); + QStringList manifestDir = dir.entryList(filters, QDir::Files); + + if (!manifestDir.isEmpty()) { + // ? + QString fileName = manifestDir.first(); + + if (fileName != "hsposterwidgetprovider.manifest") { + // Directory differs from the poster widget's directory + // which is not supported for the time being. + manifest.loadFromXml(dir.absoluteFilePath(fileName)); + widgets = manifest.widgets(); + int widgetUid = dir.dirName().toUInt(0, 16); + + // ? + for (int i=0; i HsWidgetRegistryService::widgets() +{ + return mPrivate->widgets(); +} + +/*! + \fn HsWidgetRegistryService::widgetAddedToRegistry(const QList &widgetTokenList); + Emitted when new widgets are added to registry. \a widgetTokenList + contains list of widget tokens. +*/ + +/*! + \fn HsWidgetRegistryService::widgetRemovedFromRegistry(int uid) + Emitted when a widget is removed from registry + +*/ + + +/*! + \fn HsWidgetRegistryService::posterWidgetRemovedFromRegistry(int posterWidgetId) + Emitted when a poster widget publisher is removed from cps + \a posterWidgetId Poster widget id. +*/ + +/*! + Emits the widgetAddedToRegistry() signal + \a widgetsAdded Identifies the added widgets. +*/ +void HsWidgetRegistryService::emitWidgetAddedToRegistry(const QList &widgetsAdded) +{ + emit widgetAddedToRegistry(widgetsAdded); +} + + +/*! + Emits the widgetRemovedFromRegistry() signal + \a uid HsWidget uid. +*/ +void HsWidgetRegistryService::emitWidgetRemovedFromRegistry(int uid) +{ + emit widgetRemovedFromRegistry(uid); +}