2
Copyright (C) 2010-11 Vishesh handa <handa.vish@gmail.com>
3
Copyright (C) 2011-2012 Sebastian Trueg <trueg@kde.org>
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2 of the License, or
8
(at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License along
16
with this program; if not, write to the Free Software Foundation, Inc.,
17
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
#include "resourcewatcherconnection.h"
22
#include "resourcewatcherconnectionadaptor.h"
23
#include "resourcewatchermanager.h"
25
#include <QtDBus/QDBusConnection>
26
#include <QtDBus/QDBusObjectPath>
27
#include <QtDBus/QDBusServiceWatcher>
29
Nepomuk::ResourceWatcherConnection::ResourceWatcherConnection( ResourceWatcherManager* parent )
35
Nepomuk::ResourceWatcherConnection::~ResourceWatcherConnection()
37
m_manager->removeConnection(this);
40
QDBusObjectPath Nepomuk::ResourceWatcherConnection::registerDBusObject( const QString& dbusClient, int id )
42
// build the dbus object path from the id and register the connection as a Query dbus object
43
new ResourceWatcherConnectionAdaptor( this );
44
const QString dbusObjectPath = QString::fromLatin1( "/resourcewatcher/watch%1" ).arg( id );
45
QDBusConnection::sessionBus().registerObject( dbusObjectPath, this );
47
// watch the dbus client for unregistration for auto-cleanup
48
m_serviceWatcher = new QDBusServiceWatcher( dbusClient,
49
QDBusConnection::sessionBus(),
50
QDBusServiceWatcher::WatchForUnregistration,
52
connect( m_serviceWatcher, SIGNAL(serviceUnregistered(QString)),
53
this, SLOT(close()) );
55
// finally return the dbus object path this connection can be found on
56
return QDBusObjectPath( dbusObjectPath );
59
void Nepomuk::ResourceWatcherConnection::close()
64
void Nepomuk::ResourceWatcherConnection::setResources(const QStringList &resources)
66
m_manager->setResources(this, resources);
69
void Nepomuk::ResourceWatcherConnection::addResource(const QString &resource)
71
m_manager->addResource(this, resource);
74
void Nepomuk::ResourceWatcherConnection::removeResource(const QString &resource)
76
m_manager->removeResource(this, resource);
79
void Nepomuk::ResourceWatcherConnection::setProperties(const QStringList &properties)
81
m_manager->setProperties(this, properties);
84
void Nepomuk::ResourceWatcherConnection::addProperty(const QString &property)
86
m_manager->addProperty(this, property);
89
void Nepomuk::ResourceWatcherConnection::removeProperty(const QString &property)
91
m_manager->removeProperty(this, property);
94
void Nepomuk::ResourceWatcherConnection::setTypes(const QStringList &types)
96
m_manager->setTypes(this, types);
99
void Nepomuk::ResourceWatcherConnection::addType(const QString &type)
101
m_manager->addType(this, type);
104
void Nepomuk::ResourceWatcherConnection::removeType(const QString &type)
106
m_manager->removeType(this, type);
109
#include "resourcewatcherconnection.moc"