resourcewatcher.cpp | resourcewatcher.cpp | |||
---|---|---|---|---|
skipping to change at line 24 | skipping to change at line 24 | |||
Lesser General Public License for more details. | Lesser General Public License for more details. | |||
You should have received a copy of the GNU Lesser General Public | You should have received a copy of the GNU Lesser General Public | |||
License along with this library; if not, write to the Free Software | License along with this library; if not, write to the Free Software | |||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13 01 USA | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13 01 USA | |||
*/ | */ | |||
#include "resourcewatcher.h" | #include "resourcewatcher.h" | |||
#include "resourcewatcherconnectioninterface.h" | #include "resourcewatcherconnectioninterface.h" | |||
#include "resourcewatchermanagerinterface.h" | #include "resourcewatchermanagerinterface.h" | |||
#include "resourcemanager.h" | ||||
#include <QtDBus/QDBusObjectPath> | #include <QtDBus> | |||
#include "resource.h" | #include "resource.h" | |||
#include "kurl.h" | #include "kurl.h" | |||
#include "kdebug.h" | #include "kdebug.h" | |||
namespace { | namespace { | |||
QString convertUri(const QUrl& uri) { | QString convertUri(const QUrl& uri) { | |||
return KUrl(uri).url(); | return KUrl(uri).url(); | |||
} | } | |||
skipping to change at line 62 | skipping to change at line 63 | |||
} | } | |||
class Nepomuk::ResourceWatcher::Private { | class Nepomuk::ResourceWatcher::Private { | |||
public: | public: | |||
QList<QUrl> m_types; | QList<QUrl> m_types; | |||
QList<QUrl> m_resources; | QList<QUrl> m_resources; | |||
QList<QUrl> m_properties; | QList<QUrl> m_properties; | |||
org::kde::nepomuk::ResourceWatcherConnection * m_connectionInterface; | org::kde::nepomuk::ResourceWatcherConnection * m_connectionInterface; | |||
org::kde::nepomuk::ResourceWatcher * m_watchManagerInterface; | org::kde::nepomuk::ResourceWatcher * m_watchManagerInterface; | |||
QDBusServiceWatcher* m_rwServiceWatcher; | ||||
}; | }; | |||
Nepomuk::ResourceWatcher::ResourceWatcher(QObject* parent) | Nepomuk::ResourceWatcher::ResourceWatcher(QObject* parent) | |||
: QObject(parent), | : QObject(parent), | |||
d(new Private) | d(new Private) | |||
{ | { | |||
d->m_watchManagerInterface | d->m_watchManagerInterface | |||
= new org::kde::nepomuk::ResourceWatcher( "org.kde.nepomuk.Data Management", | = new org::kde::nepomuk::ResourceWatcher( "org.kde.nepomuk.Data Management", | |||
"/resourcewatcher", | "/resourcewatcher", | |||
QDBusConnection::sess ionBus() ); | QDBusConnection::sess ionBus() ); | |||
d->m_connectionInterface = 0; | d->m_connectionInterface = 0; | |||
d->m_rwServiceWatcher = 0; | ||||
} | } | |||
Nepomuk::ResourceWatcher::~ResourceWatcher() | Nepomuk::ResourceWatcher::~ResourceWatcher() | |||
{ | { | |||
stop(); | stop(); | |||
delete d; | delete d; | |||
} | } | |||
bool Nepomuk::ResourceWatcher::start() | bool Nepomuk::ResourceWatcher::start() | |||
{ | { | |||
skipping to change at line 100 | skipping to change at line 98 | |||
// | // | |||
QList<QString> uris = convertUris(d->m_resources); | QList<QString> uris = convertUris(d->m_resources); | |||
QList<QString> props = convertUris(d->m_properties); | QList<QString> props = convertUris(d->m_properties); | |||
QList<QString> types_ = convertUris(d->m_types); | QList<QString> types_ = convertUris(d->m_types); | |||
// | // | |||
// Watch for the RW service to (re-)appear and then re-connect to make sure we always get updates | // Watch for the RW service to (re-)appear and then re-connect to make sure we always get updates | |||
// We create this watcher even if we fail to connect below. Thus, once the rw service comes up we | // We create this watcher even if we fail to connect below. Thus, once the rw service comes up we | |||
// can re-attach. | // can re-attach. | |||
// | // | |||
d->m_rwServiceWatcher = new QDBusServiceWatcher(QLatin1String("org.kde. | connect(ResourceManager::instance(), SIGNAL(nepomukSystemStarted()), th | |||
nepomuk.DataManagement"), | is, SLOT(start())); | |||
QDBusConnection::sessio | ||||
nBus()); | ||||
connect(d->m_rwServiceWatcher, SIGNAL(serviceRegistered(QString)), this | ||||
, SLOT(start())); | ||||
// | // | |||
// Create the dbus object to watch | // Create the dbus object to watch | |||
// | // | |||
QDBusPendingReply<QDBusObjectPath> reply = d->m_watchManagerInterface-> watch( uris, props, types_ ); | QDBusPendingReply<QDBusObjectPath> reply = d->m_watchManagerInterface-> watch( uris, props, types_ ); | |||
QDBusObjectPath path = reply.value(); | QDBusObjectPath path = reply.value(); | |||
if(!path.path().isEmpty()) { | if(!path.path().isEmpty()) { | |||
d->m_connectionInterface = new org::kde::nepomuk::ResourceWatcherCo nnection( "org.kde.nepomuk.DataManagement", | d->m_connectionInterface = new org::kde::nepomuk::ResourceWatcherCo nnection( "org.kde.nepomuk.DataManagement", | |||
path.path(), | path.path(), | |||
skipping to change at line 143 | skipping to change at line 139 | |||
} | } | |||
void Nepomuk::ResourceWatcher::stop() | void Nepomuk::ResourceWatcher::stop() | |||
{ | { | |||
if (d->m_connectionInterface) { | if (d->m_connectionInterface) { | |||
d->m_connectionInterface->close(); | d->m_connectionInterface->close(); | |||
delete d->m_connectionInterface; | delete d->m_connectionInterface; | |||
d->m_connectionInterface = 0; | d->m_connectionInterface = 0; | |||
} | } | |||
delete d->m_rwServiceWatcher; | disconnect(ResourceManager::instance(), SIGNAL(nepomukSystemStarted()), | |||
d->m_rwServiceWatcher = 0; | this, SLOT(start())); | |||
} | } | |||
void Nepomuk::ResourceWatcher::addProperty(const Nepomuk::Types::Property& property) | void Nepomuk::ResourceWatcher::addProperty(const Nepomuk::Types::Property& property) | |||
{ | { | |||
d->m_properties << property.uri(); | d->m_properties << property.uri(); | |||
if(d->m_connectionInterface) { | if(d->m_connectionInterface) { | |||
d->m_connectionInterface->addProperty(convertUri(property.uri())); | d->m_connectionInterface->addProperty(convertUri(property.uri())); | |||
} | } | |||
} | } | |||
End of changes. 6 change blocks. | ||||
12 lines changed or deleted | 6 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |