diff --git a/dataengines/metadata/metadataservice/metadatajob.cpp b/dataengines/metadata/metadataservice/metadatajob.cpp index 0b9c0add..393e0c45 100644 --- a/dataengines/metadata/metadataservice/metadatajob.cpp +++ b/dataengines/metadata/metadataservice/metadatajob.cpp @@ -1,141 +1,141 @@ /* * Copyright 2009 Chani Armitage * Copyright 2011 Marco Martin * Copyright 2011 Sebastian Kügler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License version 2 as * published by the Free Software Foundation * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "metadatajob.h" #include #include #include #include #include #include "bookmark.h" #include #include MetadataJob::MetadataJob(KActivities::Consumer *consumer, const QString &resourceUrl, const QString &operation, QMap ¶meters, QObject *parent) : ServiceJob(parent->objectName(), operation, parameters, parent), m_resourceUrl(resourceUrl), m_activityConsumer(consumer) { } MetadataJob::~MetadataJob() { } void MetadataJob::start() { const QString operation = operationName(); const QString activityUrl = parameters()["ActivityUrl"].toString(); QString resourceUrl = parameters()["ResourceUrl"].toString(); if (resourceUrl.isEmpty()) { resourceUrl = m_resourceUrl; } - kDebug() << "starting operation" << operation << "on the resource" << m_resourceUrl << "and activity" << activityUrl; + kDebug() << "starting operation" << operation << "on the resource" << resourceUrl << "and activity" << activityUrl; if (operation == "connectToActivity") { QString activityUrl = parameters()["ActivityUrl"].toString(); if (activityUrl.isEmpty()) { activityUrl = m_activityConsumer->currentActivity(); } Nepomuk::Resource fileRes(resourceUrl); KActivities::Info *info = new KActivities::Info(activityUrl); QUrl typeUrl; //Bookmark? if (QUrl(resourceUrl).scheme() == "http") { typeUrl = QUrl("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Bookmark"); fileRes.addType(typeUrl); fileRes.setDescription(resourceUrl); fileRes.setProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#bookmarks"), resourceUrl); } else if (resourceUrl.endsWith(QLatin1String(".desktop"))) { typeUrl = QUrl("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Application"); fileRes.addType(typeUrl); KService::Ptr service = KService::serviceByDesktopPath(QUrl(resourceUrl).path()); if (service) { fileRes.setLabel(service->name()); fileRes.addSymbol(service->icon()); } } info->linkResource(resourceUrl); info->deleteLater(); setResult(true); return; } else if (operation == "disconnectFromActivity") { QString activityUrl = parameters()["ActivityUrl"].toString(); activityUrl = m_activityConsumer->currentActivity(); QString resourceUrl = parameters()["ResourceUrl"].toString(); KActivities::Info *info = new KActivities::Info(activityUrl); info->unlinkResource(resourceUrl); info->deleteLater(); setResult(true); return; } else if (operation == "rate") { int rating = parameters()["Rating"].toInt(); Nepomuk::Resource fileRes(resourceUrl); fileRes.setRating(rating); setResult(true); return; } else if (operation == "addBookmark") { const QString url = parameters()["Url"].toString(); Nepomuk::Bookmark b(url); QUrl u(url); if (u.isValid()) { b.setBookmarks( url ); setResult(true); } else { setResult(false); } return; } else if (operation == "remove") { Nepomuk::Resource b(resourceUrl); kDebug() << "Removing resource TYPE: " << b.resourceType() << "url" << resourceUrl; b.remove(); setResult(true); return; } else if (operation == "tagResources") { const QStringList resourceUrls = parameters()["ResourceUrls"].toStringList(); const Nepomuk::Tag tag( parameters()["Tag"].toString() ); foreach (const QString &resUrl, resourceUrls) { Nepomuk::Resource r(resUrl); r.addTag(tag); } } setResult(false); } #include "metadatajob.moc"