~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy-backports

« back to all changes in this revision

Viewing changes to solid/bluez/bluezcalljob.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-09-05 20:45:14 UTC
  • Revision ID: james.westby@ubuntu.com-20070905204514-632hhspl0nvrc84i
Tags: upstream-3.93.0
ImportĀ upstreamĀ versionĀ 3.93.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  This file is part of the KDE project
 
2
    Copyright (C) 2006 Kevin Ottens <ervin@kde.org>
 
3
    Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
 
4
 
 
5
 
 
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 version 2 as published by the Free Software Foundation.
 
9
 
 
10
    This library 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 GNU
 
13
    Library General Public License for more details.
 
14
 
 
15
    You should have received a copy of the GNU Library General Public License
 
16
    along with this library; see the file COPYING.LIB.  If not, write to
 
17
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
18
    Boston, MA 02110-1301, USA.
 
19
 
 
20
*/
 
21
 
 
22
 
 
23
#include <QTimer>
 
24
#include <QStringList>
 
25
#include <kdebug.h>
 
26
 
 
27
#include "bluezcalljob.h"
 
28
 
 
29
 
 
30
BluezCallJob::BluezCallJob(const QDBusConnection &connection, const QString &dest,
 
31
                           const QString &path, const QString &interface,
 
32
                           const QString &methodName, const QList<QVariant> &params)
 
33
        : KJob(), m_connection(connection), m_dest(dest), m_path(path),
 
34
        m_iface(interface), m_method(methodName),
 
35
        m_params(params)
 
36
{}
 
37
 
 
38
BluezCallJob::~BluezCallJob()
 
39
{}
 
40
 
 
41
void BluezCallJob::start()
 
42
{
 
43
    QTimer::singleShot(0, this, SLOT(doStart()));
 
44
}
 
45
 
 
46
void BluezCallJob::kill(bool /*quietly */)
 
47
{}
 
48
 
 
49
void BluezCallJob::doStart()
 
50
{
 
51
    QDBusMessage msg = QDBusMessage::createMethodCall(m_dest, m_path,
 
52
                       m_iface, m_method);
 
53
    msg.setArguments(m_params);
 
54
 
 
55
    if (!m_connection.callWithCallback(msg, this, SLOT(callReply(const QDBusMessage &)), SLOT(callError(const QDBusError &)))) {
 
56
        setError(1);
 
57
        setErrorText(m_connection.lastError().name() + ": " + m_connection.lastError().message());
 
58
        emitResult();
 
59
    }
 
60
}
 
61
 
 
62
void BluezCallJob::callError(const QDBusError &error)
 
63
{
 
64
    setError(1);
 
65
    setErrorText(error.name() + ": " + error.message());
 
66
 
 
67
    emitResult();
 
68
}
 
69
 
 
70
void BluezCallJob::callReply(const QDBusMessage  & /*reply */)
 
71
{
 
72
    setError(0);
 
73
    emitResult();
 
74
}
 
75
 
 
76
#include "bluezcalljob.moc"