wizardproviders/ftuwizardprovider/src/ftumanifestparser.cpp
changeset 9 aa22d2c19e57
parent 0 c464cd7e2753
equal deleted inserted replaced
7:446dc0e90e84 9:aa22d2c19e57
    24 #include <QFile>
    24 #include <QFile>
    25 #include <QStringList>
    25 #include <QStringList>
    26 #include <QFileInfo>
    26 #include <QFileInfo>
    27 #include <QDir>
    27 #include <QDir>
    28 #include <QDebug>
    28 #include <QDebug>
    29 
    29 #include "ftuwizardprovider_global.h"
    30 #ifdef Q_OS_SYMBIAN
    30 #ifdef Q_OS_SYMBIAN
    31 
    31 
    32 #include <XQSettingsManager> // for reading cenrep keys
    32 #include <XQSettingsManager> // for reading cenrep keys
    33 #endif // Q_OS_SYMBIAN
    33 #endif // Q_OS_SYMBIAN
    34 
    34 
    68         QFileInfo drive = drives.at(i);
    68         QFileInfo drive = drives.at(i);
    69         QString driveLetter = drive.absolutePath();
    69         QString driveLetter = drive.absolutePath();
    70         QString path = driveLetter + manifestPath;
    70         QString path = driveLetter + manifestPath;
    71         if(QDir(path).exists())
    71         if(QDir(path).exists())
    72         {
    72         {
    73             qDebug() << "ftu:: append to path list: " << path;
    73             QDEBUG("ftu:: append to path list: " << path;)
    74             pathList << path;
    74             pathList << path;
    75         }
    75         }
    76     }      
    76     }      
    77     // Read the configured plugin list.
    77     // Read the configured plugin list.
    78     QStringList filesToRead = readManifestFilesFromConfig();
    78     QStringList filesToRead = readManifestFilesFromConfig();
    85         // Use the configured list as a filter while getting the 
    85         // Use the configured list as a filter while getting the 
    86         // manifest files.
    86         // manifest files.
    87         dir.setNameFilters(filesToRead);
    87         dir.setNameFilters(filesToRead);
    88         QStringList entries = dir.entryList(filesToRead, QDir::Files);
    88         QStringList entries = dir.entryList(filesToRead, QDir::Files);
    89     
    89     
    90         qDebug() << "ftu: Configured manifest file count " 
    90         QDEBUG("ftu: Configured manifest file count " 
    91                  << filesToRead.count()
    91                  << filesToRead.count()
    92                  << " found manifest files from system " << entries.count();
    92                  << " found manifest files from system " << entries.count();)
    93         
    93         
    94         // Go through the configured list and find the manifest files.
    94         // Go through the configured list and find the manifest files.
    95         for(int j=0; j < filesToRead.count() ; ++j)
    95         for(int j=0; j < filesToRead.count() ; ++j)
    96         {
    96         {
    97             int index = entries.indexOf(filesToRead[j]);
    97             int index = entries.indexOf(filesToRead[j]);
    98             qDebug() << "ftu:reading manifest file from "<< index;
    98             QDEBUG("ftu:reading manifest file from "<< index;)
    99             if(index > -1 && index <= entries.count())
    99             if(index > -1 && index <= entries.count())
   100             {
   100             {
   101                 QString fileName = entries[index]; 
   101                 QString fileName = entries[index]; 
   102                 qDebug() << "ftu:: loading from manifest file: " << fileName;
   102                 QDEBUG("ftu:: loading from manifest file: " << fileName;)
   103                 QString path = loadFromXml(dir.absoluteFilePath(fileName));
   103                 QString path = loadFromXml(dir.absoluteFilePath(fileName));
   104                 qDebug() << "ftu:: path from manifest: " << path;
   104                 QDEBUG("ftu:: path from manifest: " << path;)
   105                 if(!path.isEmpty())
   105                 if(!path.isEmpty())
   106                 {
   106                 {
   107                     dllNameList << path;
   107                     dllNameList << path;
   108                 }
   108                 }
   109             }
   109             }
   130     
   130     
   131     bool ok = false;
   131     bool ok = false;
   132     int numberOfPlugins = settingsManager->readItemValue(
   132     int numberOfPlugins = settingsManager->readItemValue(
   133                                               numberOfPluginsKey).toInt(&ok);
   133                                               numberOfPluginsKey).toInt(&ok);
   134 
   134 
   135     qDebug() << "Ftu:FtuManifestParser reading the nbr of plugins resulted: "
   135     QDEBUG("Ftu:FtuManifestParser reading the nbr of plugins resulted: "
   136              << ok;
   136              << ok;)
   137     
   137     
   138     if(ok)
   138     if(ok)
   139     {
   139     {
   140         qDebug() << "Ftu:reading config for " << numberOfPlugins 
   140     QDEBUG("Ftu:reading config for " << numberOfPlugins 
   141                  << " plugins";
   141                  << " plugins";)
   142         
   142         
   143         
   143         
   144         for(int i=1; i <= numberOfPlugins ; ++i)
   144         for(int i=1; i <= numberOfPlugins ; ++i)
   145         {
   145         {
   146             XQSettingsKey fileKey(XQSettingsKey::TargetCentralRepository,
   146             XQSettingsKey fileKey(XQSettingsKey::TargetCentralRepository,
   147                                   KCrUidFtuWizardProvider,
   147                                   KCrUidFtuWizardProvider,
   148                                   KFtuNumberOfWizardPlugins + i);
   148                                   KFtuNumberOfWizardPlugins + i);
   149             
   149             
   150             QString file = settingsManager->readItemValue(fileKey, 
   150             QString file = settingsManager->readItemValue(fileKey, 
   151                                    XQSettingsManager::TypeString).toString();
   151                                    XQSettingsManager::TypeString).toString();
   152             qDebug() << "Ftu:Reading filename from conf :" << file;            
   152             QDEBUG("Ftu:Reading filename from conf :" << file;)            
   153             filesFromConf << file;
   153             filesFromConf << file;
   154         }
   154         }
   155     }
   155     }
   156     delete settingsManager;
   156     delete settingsManager;
   157 #else
   157 #else
   170 // ---------------------------------------------------------------------------
   170 // ---------------------------------------------------------------------------
   171 //
   171 //
   172 QString FtuManifestParser::loadFromXml(const QString& aFileName)
   172 QString FtuManifestParser::loadFromXml(const QString& aFileName)
   173 {
   173 {
   174 
   174 
   175     qDebug() << "ftu:: ManifestParser::loadFromXml " << aFileName;
   175     QDEBUG("ftu:: ManifestParser::loadFromXml " << aFileName;)
   176     QFile file(aFileName);
   176     QFile file(aFileName);
   177     
   177     
   178     if(!file.exists())
   178     if(!file.exists())
   179     {
   179     {
   180         qDebug() << "ftu: file does not exist";
   180         QDEBUG("ftu: file does not exist";)
   181         return QString();
   181         return QString();
   182     }
   182     }
   183 
   183 
   184     QDomDocument document;
   184     QDomDocument document;
   185     if(!document.setContent(&file))
   185     if(!document.setContent(&file))
   188     }
   188     }
   189 
   189 
   190     QDomElement element = document.documentElement();
   190     QDomElement element = document.documentElement();
   191     if(element.tagName() != "plugin")
   191     if(element.tagName() != "plugin")
   192     {
   192     {
   193         qDebug() << "ftu: Tag name plugin not found";
   193         QDEBUG("ftu: Tag name plugin not found";)
   194         return QString();
   194         return QString();
   195     }
   195     }
   196 
   196 
   197     QDomNodeList plugins = element.elementsByTagName("runtime");
   197     QDomNodeList plugins = element.elementsByTagName("runtime");
   198 
   198 
   199     for(int i = 0; i < plugins.count(); ++i)
   199     for(int i = 0; i < plugins.count(); ++i)
   200     {
   200     {
   201         element = plugins.at(i).toElement();
   201         element = plugins.at(i).toElement();
   202         QString attr = parseAttribute(element, "library");
   202         QString attr = parseAttribute(element, "library");
   203         qDebug() << "ftu::parsed attr " << attr;
   203         QDEBUG("ftu::parsed attr " << attr;)
   204         return attr;
   204         return attr;
   205     }
   205     }
   206     return QString();
   206     return QString();
   207 }
   207 }
   208 
   208 
   215                                           const QString& attributeName) const
   215                                           const QString& attributeName) const
   216 {
   216 {
   217     QDomAttr attribute = element.attributeNode(attributeName);
   217     QDomAttr attribute = element.attributeNode(attributeName);
   218     if(attribute.isNull() || attribute.value().isEmpty())
   218     if(attribute.isNull() || attribute.value().isEmpty())
   219     {
   219     {
   220         qDebug() << "ftu: attribute not parsed [attr name]" << attributeName;
   220         QDEBUG("ftu: attribute not parsed [attr name]" << attributeName;)
   221         return QString();
   221         return QString();
   222     }
   222     }
   223 
   223 
   224     return attribute.value();
   224     return attribute.value();
   225 }
   225 }