• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Nepomuk-Core

  • sources
  • kde-4.12
  • kdelibs
  • nepomuk-core
  • libnepomukcore
  • datamanagement
storeresourcesjob.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Nepomuk KDE project.
3  Copyright (C) 2011 Vishesh Handa <handa.vish@gmail.com>
4  Copyright (C) 2011 Sebastian Trueg <trueg@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) version 3, or any
10  later version accepted by the membership of KDE e.V. (or its
11  successor approved by the membership of KDE e.V.), which shall
12  act as a proxy defined in Section 6 of version 3 of the license.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #include "storeresourcesjob.h"
24 #include "datamanagementinterface.h"
25 #include "simpleresourcegraph.h"
26 #include "dbustypes.h"
27 #include "genericdatamanagementjob_p.h"
28 
29 #include <QtDBus/QDBusConnection>
30 #include <QtDBus/QDBusPendingReply>
31 #include <QtDBus/QDBusPendingCallWatcher>
32 
33 #include <QtCore/QHash>
34 #include <QtCore/QUrl>
35 
36 #include <KComponentData>
37 #include <KUrl>
38 #include <KDebug>
39 
40 class Nepomuk2::StoreResourcesJob::Private {
41 public:
42  Nepomuk2::StoreResourcesJob *q;
43  QHash<QUrl, QUrl> m_mappings;
44 
45  void _k_slotDBusCallFinished(QDBusPendingCallWatcher* watcher);
46 };
47 
48 Nepomuk2::StoreResourcesJob::StoreResourcesJob(const Nepomuk2::SimpleResourceGraph& resources,
49  Nepomuk2::StoreIdentificationMode identificationMode,
50  Nepomuk2::StoreResourcesFlags flags,
51  const QHash< QUrl, QVariant >& additionalMetadata,
52  const KComponentData& component)
53  : KJob(),
54  d( new Nepomuk2::StoreResourcesJob::Private )
55 {
56  d->q = this;
57 
58  org::kde::nepomuk::DataManagement* dms = Nepomuk2::dataManagementDBusInterface();
59  QDBusPendingCallWatcher* dbusCallWatcher
60  = new QDBusPendingCallWatcher(dms->storeResources( resources.toList(), identificationMode,
61  flags, additionalMetadata,
62  component.componentName() ));
63 
64  connect(dbusCallWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
65  this, SLOT(_k_slotDBusCallFinished(QDBusPendingCallWatcher*)));
66 }
67 
68 Nepomuk2::StoreResourcesJob::~StoreResourcesJob()
69 {
70  delete d;
71 }
72 
73 void Nepomuk2::StoreResourcesJob::start()
74 {
75  // Nothing to do
76 }
77 
78 QHash< QUrl, QUrl > Nepomuk2::StoreResourcesJob::mappings() const
79 {
80  return d->m_mappings;
81 }
82 
83 void Nepomuk2::StoreResourcesJob::Private::_k_slotDBusCallFinished(QDBusPendingCallWatcher* watcher)
84 {
85  QDBusPendingReply< QHash<QString,QString> > reply = *watcher;
86  if (reply.isError()) {
87  QDBusError error = reply.error();
88  q->setError(int(error.type()));
89  q->setErrorText(error.message());
90  }
91  else {
92  m_mappings.clear();
93  QHash<QString, QString> mappings = reply.value();
94  QHash<QString, QString>::const_iterator it = mappings.constBegin();
95  for( ; it != mappings.constEnd(); it++ ) {
96  m_mappings.insert( KUrl( it.key() ), KUrl( it.value() ) );
97  }
98  }
99 
100  watcher->deleteLater();
101  q->emitResult();
102 }
103 
104 #include "storeresourcesjob.moc"
Nepomuk2::StoreIdentificationMode
StoreIdentificationMode
The identification mode used by storeResources().
Definition: datamanagement.h:349
storeresourcesjob.h
Nepomuk2::StoreResourcesJob::start
void start()
Definition: storeresourcesjob.cpp:73
datamanagementinterface.h
QHash
Nepomuk2::SimpleResourceGraph
Definition: simpleresourcegraph.h:48
Nepomuk2::SimpleResourceGraph::toList
QList< SimpleResource > toList() const
Definition: simpleresourcegraph.cpp:192
Nepomuk2::StoreResourcesJob::~StoreResourcesJob
~StoreResourcesJob()
Definition: storeresourcesjob.cpp:68
Nepomuk2::StoreResourcesJob::mappings
QHash< QUrl, QUrl > mappings() const
Definition: storeresourcesjob.cpp:78
simpleresourcegraph.h
Nepomuk2::StoreResourcesJob
Definition: storeresourcesjob.h:34
OrgKdeNepomukDataManagementInterface::storeResources
QDBusPendingReply storeResources(const QList< Nepomuk2::SimpleResource > &resources, int identificationMode, int flags, Nepomuk2::PropertyHash additionalMetadata, const QString &app)
Definition: datamanagementinterface.h:180
KJob
dbustypes.h
OrgKdeNepomukDataManagementInterface
Definition: datamanagementinterface.h:30
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:09 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk-Core

Skip menu "Nepomuk-Core"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal