2
* This file is part of Soprano Project.
4
* Copyright (C) 2007 Sebastian Trueg <trueg@kde.org>
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Library General Public
8
* License as published by the Free Software Foundation; either
9
* version 2 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Library General Public License for more details.
16
* You should have received a copy of the GNU Library General Public License
17
* along with this library; see the file COPYING.LIB. If not, write to
18
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
* Boston, MA 02110-1301, USA.
22
#include "dbusserveradaptor.h"
24
#include "../servercore.h"
25
#include "dbusmodeladaptor.h"
26
#include "modelwrapper.h"
28
#include <soprano/model.h>
30
#include <QtCore/QHash>
32
class Soprano::Server::DBusServerAdaptor::Private
36
QHash<Model*, QString> modelDBusObjectPaths;
40
Soprano::Server::DBusServerAdaptor::DBusServerAdaptor( ServerCore* parent )
41
: QDBusAbstractAdaptor( parent ),
47
Soprano::Server::DBusServerAdaptor::~DBusServerAdaptor()
52
QStringList Soprano::Server::DBusServerAdaptor::allModels( const QDBusMessage& m )
54
// handle method call org.soprano.Server.allModels
55
QStringList names = d->core->allModels();
56
if ( d->core->lastError() ) {
57
DBus::sendErrorReply( m, d->core->lastError() );
62
QString Soprano::Server::DBusServerAdaptor::createModel( const QString& name, const QDBusMessage& m )
64
// handle method call org.soprano.Server.createModel
65
Model* model = d->core->model( name );
67
QHash<Model*, QString>::const_iterator it = d->modelDBusObjectPaths.find( model );
68
if ( it != d->modelDBusObjectPaths.constEnd() ) {
72
// FIXME: memory leak!
73
ModelWrapper* mw = new ModelWrapper( model );
74
( void )new DBusModelAdaptor( model, mw );
75
QString objectPath = "/Model_" + name;
76
QDBusConnection::sessionBus().registerObject( objectPath, mw );
77
d->modelDBusObjectPaths.insert( model, objectPath );
82
DBus::sendErrorReply( m, d->core->lastError() );
87
#include "dbusserveradaptor.moc"