Home | History | Annotate | Download | only in symbian
      1 /*
      2     Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
      3 
      4     This library is free software; you can redistribute it and/or
      5     modify it under the terms of the GNU Library General Public
      6     License as published by the Free Software Foundation; either
      7     version 2 of the License, or (at your option) any later version.
      8 
      9     This library is distributed in the hope that it will be useful,
     10     but WITHOUT ANY WARRANTY; without even the implied warranty of
     11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12     Library General Public License for more details.
     13 
     14     You should have received a copy of the GNU Library General Public License
     15     along with this library; see the file COPYING.LIB.  If not, write to
     16     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     17     Boston, MA 02110-1301, USA.
     18 */
     19 #include "config.h"
     20 #include "PluginDatabase.h"
     21 
     22 #include <QFileInfo>
     23 #include <f32file.h>
     24 
     25 static const char QTPLUGIN_FILTER[] = "*.qtplugin";
     26 static const char QT_PLUGIN_FOLDER[] = ":\\resource\\qt\\plugins\\npqtplugins\\";
     27 
     28 namespace WebCore {
     29 
     30 Vector<String> PluginDatabase::defaultPluginDirectories()
     31 {
     32     Vector<String> directories;
     33     //find the installation drive
     34     TDriveList drivelist;
     35     TChar driveLetter;
     36     RFs fsSession;
     37 
     38     if (fsSession.Connect() == KErrNone && fsSession.DriveList(drivelist) == KErrNone) {
     39         for (TInt driveNumber = EDriveA; driveNumber <= EDriveZ; driveNumber++) {
     40             if (drivelist[driveNumber] && fsSession.DriveToChar(driveNumber, driveLetter) == KErrNone) {
     41                 QString driveStringValue(QChar((uint)driveLetter.GetUpperCase()));
     42                 QString stubDirPath;
     43                 stubDirPath.append(driveStringValue);
     44                 stubDirPath.append(QT_PLUGIN_FOLDER);
     45                 if (QFileInfo(stubDirPath).exists())
     46                     directories.append(stubDirPath);
     47             }
     48         }
     49     }
     50 
     51     fsSession.Close();
     52     return directories;
     53 }
     54 
     55 bool PluginDatabase::isPreferredPluginDirectory(const String& path)
     56 {
     57     return true;
     58 }
     59 
     60 void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const
     61 {
     62     // FIXME: This should be a case insensitive set.
     63     HashSet<String> uniqueFilenames;
     64 
     65     String fileNameFilter(QTPLUGIN_FILTER);
     66 
     67     Vector<String>::const_iterator dirsEnd = m_pluginDirectories.end();
     68     for (Vector<String>::const_iterator dIt = m_pluginDirectories.begin(); dIt != dirsEnd; ++dIt) {
     69         Vector<String> pluginPaths = listDirectory(*dIt, fileNameFilter);
     70         Vector<String>::const_iterator pluginsEnd = pluginPaths.end();
     71         for (Vector<String>::const_iterator pIt = pluginPaths.begin(); pIt != pluginsEnd; ++pIt) {
     72             if (!fileExists(*pIt))
     73                 continue;
     74             paths.add(*pIt);
     75         }
     76     }
     77 }
     78 
     79 }
     80