contentstorage/caclient/stub/src/hswidgetregistryservice.cpp
changeset 99 7aaf39b772ac
parent 93 82b66994846c
child 119 50e220be30d1
equal deleted inserted replaced
98:d2f833ab7940 99:7aaf39b772ac
    65 }
    65 }
    66 
    66 
    67 /*!
    67 /*!
    68     ?Qt_style_documentation
    68     ?Qt_style_documentation
    69 */
    69 */
    70 QList<HsWidgetToken> HsWidgetRegistryServicePrivate::widgets()
    70 QList<HsWidgetComponentDescriptor> HsWidgetRegistryServicePrivate::widgets()
    71 {
    71 {
    72     QList<HsWidgetToken> widgets;
    72     QList<HsWidgetComponentDescriptor> widgets;
    73     QMapIterator<QString, QStringList> i(mManifestDirectories);
    73     QMapIterator<QString, QStringList> i(mManifestDirectories);
    74 
    74 
    75     while (i.hasNext()) {
    75     while (i.hasNext()) {
    76         i.next();
    76         i.next();
    77         QStringList manifestFileList = i.value();
    77         QStringList manifestFileList = i.value();
    86 }
    86 }
    87 
    87 
    88 /*!
    88 /*!
    89     ?Qt_style_documentation
    89     ?Qt_style_documentation
    90 */
    90 */
       
    91 /*
    91 IHsWidgetProvider *HsWidgetRegistryServicePrivate::loadProviderFromPlugin(
    92 IHsWidgetProvider *HsWidgetRegistryServicePrivate::loadProviderFromPlugin(
    92     const QString &pluginName)
    93     const QString &pluginName)
    93 {
    94 {
    94     QPluginLoader loader(pluginName);
    95     QPluginLoader loader(pluginName);
    95     QObject *plugin = loader.instance();
    96     QObject *plugin = loader.instance();
   107     }
   108     }
   108 
   109 
   109     // qDebug("Widget provider load failed - Not found.")
   110     // qDebug("Widget provider load failed - Not found.")
   110     return 0;
   111     return 0;
   111 }
   112 }
       
   113 */
   112 
   114 
   113 /*!
   115 /*!
   114     ?Qt_style_documentation
   116     ?Qt_style_documentation
   115 */
   117 */
   116 QStringList HsWidgetRegistryServicePrivate::readManifestDirectories(const QString &path)
   118 QStringList HsWidgetRegistryServicePrivate::readManifestDirectories(const QString &path)
   149 }
   151 }
   150 
   152 
   151 /*!
   153 /*!
   152     ?Qt_style_documentation
   154     ?Qt_style_documentation
   153 */
   155 */
   154 QList<HsWidgetToken> HsWidgetRegistryServicePrivate::readManifestFile(
   156 QList<HsWidgetComponentDescriptor> HsWidgetRegistryServicePrivate::readManifestFile(
   155     const QString &manifestFilePath)
   157     const QString &manifestFilePath)
   156 {
   158 {
   157     QList<HsWidgetToken> widgets;
   159     QList<HsWidgetComponentDescriptor> widgets;
   158     QStringList filters("*.manifest");
   160     QStringList filters("*.manifest");
   159     QDir dir(manifestFilePath);
   161     QDir dir(manifestFilePath);
   160     QStringList manifestDir = dir.entryList(filters, QDir::Files);
   162     QStringList manifestDir = dir.entryList(filters, QDir::Files);
   161 
   163 
   162     if (!manifestDir.isEmpty()) {
   164     if (!manifestDir.isEmpty()) {
   163         // ?
   165         // ?
   164         QString fileName = manifestDir.first();
   166         QString fileName = manifestDir.first();
   165         HsWidgetComponentParser componentParser(dir.absoluteFilePath(fileName));
   167         HsWidgetComponentParser componentParser(dir.absoluteFilePath(fileName));
   166         if ( !componentParser.error() ) {
   168         if ( !componentParser.error() ) {
   167             HsWidgetToken widgetToken;
   169             
   168             HsWidgetComponentDescriptor widgetDescriptor = componentParser.widgetComponentDescriptor();
   170             HsWidgetComponentDescriptor widgetDescriptor = componentParser.widgetComponentDescriptor();            
   169             widgetToken.mUri = widgetDescriptor.uri;
   171             widgetDescriptor.library = manifestFilePath + "/" + widgetDescriptor.uri + ".dll";
   170             widgetToken.mLibrary = manifestFilePath + "/" + widgetDescriptor.uri + ".dll";
       
   171             widgetToken.mTitle = widgetDescriptor.title;
       
   172             if (widgetDescriptor.iconUri.length() > 0 ) {
   172             if (widgetDescriptor.iconUri.length() > 0 ) {
   173                 widgetToken.mIconUri = manifestFilePath + "/" + widgetDescriptor.iconUri;
   173                 widgetDescriptor.iconUri = manifestFilePath + "/" + widgetDescriptor.iconUri;
   174             }
   174             }            
   175             widgetToken.mDescription = widgetDescriptor.description;
   175             if (widgetDescriptor.previewImage.length() > 0 ) {
       
   176                 widgetDescriptor.previewImage = manifestFilePath + "/" + widgetDescriptor.previewImage;
       
   177             }            
       
   178 
   176             int widgetUid = dir.dirName().toUInt(0, 16);
   179             int widgetUid = dir.dirName().toUInt(0, 16);
   177             widgetToken.mUid = widgetUid;
   180             widgetDescriptor.uid = widgetUid;
   178             widgets << widgetToken;
   181             widgets << widgetDescriptor;
   179             qDebug() << "HsWidgetRegistryServicePrivate::readManifestFile - " \
   182             qDebug() << "HsWidgetRegistryServicePrivate::readManifestFile - " \
   180                      "widget added: " << fileName;
   183                      "widget added: " << fileName;
   181         }
   184         }
   182 #if 0
       
   183 
       
   184         if (fileName != "hsposterwidgetprovider.manifest") {
       
   185             // Directory differs from the poster widget's directory
       
   186             // which is not supported for the time being.
       
   187 //            manifest.loadFromXml(dir.absoluteFilePath(fileName));
       
   188 //            widgets = manifest.widgets();
       
   189             int widgetUid = dir.dirName().toUInt(0, 16);
       
   190 
       
   191             // ?
       
   192             for (int i=0; i<widgets.count(); i++) {
       
   193                 widgets[i].mUid = widgetUid;
       
   194                 widgets[i].mLibrary = manifestFilePath + "/" + widgets[i].mLibrary;
       
   195                 if (widgets[i].mIconUri != "") {
       
   196                     // ?
       
   197                     widgets[i].mIconUri = manifestFilePath + "/" + widgets[i].mIconUri;
       
   198                 }
       
   199             }
       
   200 
       
   201             qDebug() << "HsWidgetRegistryServicePrivate::readManifestFile - " \
       
   202                      "widget added: " << fileName;
       
   203         }
       
   204 #endif                
       
   205     }
   185     }
   206     return widgets;
   186     return widgets;
   207 }
   187 }
   208 
   188 
   209 /*!
   189 /*!
   217 
   197 
   218     // ?
   198     // ?
   219     for(int i=0; i < pathList.count(); i++) {
   199     for(int i=0; i < pathList.count(); i++) {
   220         QDir registryDir(pathList.at(i));
   200         QDir registryDir(pathList.at(i));
   221 
   201 
   222     	if(!registryDir.exists()) {
   202         if(!registryDir.exists()) {
   223     		// ?
   203             // ?
   224             registryDir.mkpath(pathList.at(i));
   204             registryDir.mkpath(pathList.at(i));
   225         }
   205         }
   226     }
   206     }
   227 
   207 
   228     mFileSystemWatcher.removePaths(QStringList(mManifestDirectories.keys()));
   208     mFileSystemWatcher.removePaths(QStringList(mManifestDirectories.keys()));
   264 void HsWidgetRegistryServicePrivate::installerStateChanged(int newValue)
   244 void HsWidgetRegistryServicePrivate::installerStateChanged(int newValue)
   265 {
   245 {
   266     Q_UNUSED(newValue);
   246     Q_UNUSED(newValue);
   267     /*
   247     /*
   268     if ((newValue & KSASwisOperationMask) == ESASwisNone) {
   248     if ((newValue & KSASwisOperationMask) == ESASwisNone) {
   269     	// ?
   249         // ?
   270         mInstallerObserver.unSubscribe();
   250         mInstallerObserver.unSubscribe();
   271         mInstallerObserver.disconnect();
   251         mInstallerObserver.disconnect();
   272         QStringList originalList = mManifestDirectories.value(mLatestChangedDirectory);
   252         QStringList originalList = mManifestDirectories.value(mLatestChangedDirectory);
   273         QStringList currentList = readManifestDirectories(mLatestChangedDirectory);
   253         QStringList currentList = readManifestDirectories(mLatestChangedDirectory);
   274         doWidgetAdd(mLatestChangedDirectory, originalList, currentList);
   254         doWidgetAdd(mLatestChangedDirectory, originalList, currentList);
   315 
   295 
   316 /*!
   296 /*!
   317     Fetch available widgets information
   297     Fetch available widgets information
   318     Return List of widget tokens.
   298     Return List of widget tokens.
   319 */
   299 */
   320 QList<HsWidgetToken> HsWidgetRegistryService::widgets()
   300 QList<HsWidgetComponentDescriptor> HsWidgetRegistryService::widgets()
   321 {
   301 {
   322     return mPrivate->widgets();
   302     return mPrivate->widgets();
   323 }
   303 }
   324 
   304 
   325 /*!
   305 /*!
   343 
   323 
   344 /*!
   324 /*!
   345     Emits the widgetAddedToRegistry() signal
   325     Emits the widgetAddedToRegistry() signal
   346     \a widgetsAdded Identifies the added widgets.
   326     \a widgetsAdded Identifies the added widgets.
   347 */
   327 */
   348 void HsWidgetRegistryService::emitWidgetAddedToRegistry(const QList<HsWidgetToken> &widgetsAdded)
   328 void HsWidgetRegistryService::emitWidgetAddedToRegistry(const QList<HsWidgetComponentDescriptor> &widgetsAdded)
   349 {
   329 {
   350     emit widgetAddedToRegistry(widgetsAdded);
   330     emit widgetAddedToRegistry(widgetsAdded);
   351 }
   331 }
   352 
   332 
   353 
   333