Commit 03af06da authored by Raphael Kubo da Costa (rakuco)'s avatar Raphael Kubo da Costa (rakuco)
Browse files

Move the plugin location code elsewhere.

svn path=/trunk/KDE/kdeutils/ark/; revision=991477
parent f0b82c44
......@@ -42,10 +42,10 @@ static bool comparePlugins(const KService::Ptr &p1, const KService::Ptr &p2)
return (p1->property("X-KDE-Priority").toInt()) > (p2->property("X-KDE-Priority").toInt());
}
static QString determineMimeType(const QString & filename, const QString & defaultMimeType)
static QString determineMimeType(const QString & filename, const QString & fixedMimeType)
{
if (!defaultMimeType.isEmpty())
return defaultMimeType;
if (!fixedMimeType.isEmpty())
return fixedMimeType;
if (!QFile::exists(filename))
return KMimeType::findByPath(filename)->name();
......@@ -61,31 +61,30 @@ static QString determineMimeType(const QString & filename, const QString & defau
return KMimeType::findByNameAndContent(filename, buffer)->name();
}
namespace Kerfuffle
static KService::List findPluginOffers(const QString& filename, const QString& fixedMimeType)
{
KService::List offers;
Archive *factory(const QString & filename, const QString & requestedMimeType)
{
kDebug();
QString mimeType = determineMimeType(filename, fixedMimeType);
qRegisterMetaType<ArchiveEntry>("ArchiveEntry");
if (!mimeType.isEmpty()) {
offers = KMimeTypeTrader::self()->query(mimeType, "Kerfuffle/Plugin", "(exist Library)");
qSort(offers.begin(), offers.end(), comparePlugins);
}
QString mimeType = determineMimeType(filename, requestedMimeType);
if (mimeType.isEmpty())
return NULL;
return offers;
}
KService::List offers = KMimeTypeTrader::self()->query(mimeType, "Kerfuffle/Plugin", "(exist Library)");
namespace Kerfuffle
{
if (offers.isEmpty()) {
kDebug() << "Trying to find the mimetype by looking at file content";
Archive *factory(const QString & filename, const QString & fixedMimeType)
{
kDebug();
int acc;
QString mimeType = KMimeType::findByFileContent(filename, &acc)->name();
kDebug() << mimeType << acc;
offers = KMimeTypeTrader::self()->query(mimeType, "Kerfuffle/Plugin", "(exist Library)");
}
qRegisterMetaType<ArchiveEntry>("ArchiveEntry");
qSort(offers.begin(), offers.end(), comparePlugins);
KService::List offers = findPluginOffers(filename, fixedMimeType);
if (!offers.isEmpty()) {
QString libraryName = offers[ 0 ]->library();
......
......@@ -96,7 +96,7 @@ public:
};
KERFUFFLE_EXPORT Archive* factory(const QString & filename, const QString & requestedMimeType = QString());
KERFUFFLE_EXPORT Archive* factory(const QString & filename, const QString & fixedMimeType = QString());
KERFUFFLE_EXPORT QStringList supportedMimeTypes();
KERFUFFLE_EXPORT QStringList supportedWriteMimeTypes();
} // namespace Kerfuffle
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment