~ubuntu-branches/ubuntu/quantal/kde-runtime/quantal

« back to all changes in this revision

Viewing changes to nepomuk/services/storage/resourcewatcherconnection.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2012-06-03 21:50:00 UTC
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20120603215000-vn7oarsq0ynrydj5
Tags: upstream-4.8.80
Import upstream version 4.8.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    Copyright (C) 2010-11 Vishesh handa <handa.vish@gmail.com>
3
 
    Copyright (C) 2011-2012 Sebastian Trueg <trueg@kde.org>
4
 
 
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.
9
 
 
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.
14
 
 
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.
18
 
*/
19
 
 
20
 
 
21
 
#include "resourcewatcherconnection.h"
22
 
#include "resourcewatcherconnectionadaptor.h"
23
 
#include "resourcewatchermanager.h"
24
 
 
25
 
#include <QtDBus/QDBusConnection>
26
 
#include <QtDBus/QDBusObjectPath>
27
 
#include <QtDBus/QDBusServiceWatcher>
28
 
 
29
 
Nepomuk::ResourceWatcherConnection::ResourceWatcherConnection( ResourceWatcherManager* parent )
30
 
    : QObject( parent ),
31
 
      m_manager(parent)
32
 
{
33
 
}
34
 
 
35
 
Nepomuk::ResourceWatcherConnection::~ResourceWatcherConnection()
36
 
{
37
 
    m_manager->removeConnection(this);
38
 
}
39
 
 
40
 
QDBusObjectPath Nepomuk::ResourceWatcherConnection::registerDBusObject( const QString& dbusClient, int id )
41
 
{
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 );
46
 
 
47
 
    // watch the dbus client for unregistration for auto-cleanup
48
 
    m_serviceWatcher = new QDBusServiceWatcher( dbusClient,
49
 
                                                QDBusConnection::sessionBus(),
50
 
                                                QDBusServiceWatcher::WatchForUnregistration,
51
 
                                                this );
52
 
    connect( m_serviceWatcher, SIGNAL(serviceUnregistered(QString)),
53
 
             this, SLOT(close()) );
54
 
 
55
 
    // finally return the dbus object path this connection can be found on
56
 
    return QDBusObjectPath( dbusObjectPath );
57
 
}
58
 
 
59
 
void Nepomuk::ResourceWatcherConnection::close()
60
 
{
61
 
    deleteLater();
62
 
}
63
 
 
64
 
void Nepomuk::ResourceWatcherConnection::setResources(const QStringList &resources)
65
 
{
66
 
    m_manager->setResources(this, resources);
67
 
}
68
 
 
69
 
void Nepomuk::ResourceWatcherConnection::addResource(const QString &resource)
70
 
{
71
 
    m_manager->addResource(this, resource);
72
 
}
73
 
 
74
 
void Nepomuk::ResourceWatcherConnection::removeResource(const QString &resource)
75
 
{
76
 
    m_manager->removeResource(this, resource);
77
 
}
78
 
 
79
 
void Nepomuk::ResourceWatcherConnection::setProperties(const QStringList &properties)
80
 
{
81
 
    m_manager->setProperties(this, properties);
82
 
}
83
 
 
84
 
void Nepomuk::ResourceWatcherConnection::addProperty(const QString &property)
85
 
{
86
 
    m_manager->addProperty(this, property);
87
 
}
88
 
 
89
 
void Nepomuk::ResourceWatcherConnection::removeProperty(const QString &property)
90
 
{
91
 
    m_manager->removeProperty(this, property);
92
 
}
93
 
 
94
 
void Nepomuk::ResourceWatcherConnection::setTypes(const QStringList &types)
95
 
{
96
 
    m_manager->setTypes(this, types);
97
 
}
98
 
 
99
 
void Nepomuk::ResourceWatcherConnection::addType(const QString &type)
100
 
{
101
 
    m_manager->addType(this, type);
102
 
}
103
 
 
104
 
void Nepomuk::ResourceWatcherConnection::removeType(const QString &type)
105
 
{
106
 
    m_manager->removeType(this, type);
107
 
}
108
 
 
109
 
#include "resourcewatcherconnection.moc"