| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtDBus module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qdbusserver.h" | - |
| 43 | #include "qdbusconnection_p.h" | - |
| 44 | #include "qdbusconnectionmanager_p.h" | - |
| 45 | | - |
| 46 | #ifndef QT_NO_DBUS | - |
| 47 | | - |
| 48 | QT_BEGIN_NAMESPACE | - |
| 49 | | - |
| 50 | /*! | - |
| 51 | \class QDBusServer | - |
| 52 | \inmodule QtDBus | - |
| 53 | | - |
| 54 | \brief The QDBusServer class provides peer-to-peer communication | - |
| 55 | between processes on the same computer. | - |
| 56 | */ | - |
| 57 | | - |
| 58 | /*! | - |
| 59 | Constructs a QDBusServer with the given \a address, and the given | - |
| 60 | \a parent. | - |
| 61 | */ | - |
| 62 | QDBusServer::QDBusServer(const QString &address, QObject *parent) | - |
| 63 | : QObject(parent) | - |
| 64 | { | - |
| 65 | if (address.isEmpty()) partially evaluated: address.isEmpty()| no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
| 66 | return; | 0 |
| 67 | | - |
| 68 | if (!qdbus_loadLibDBus()) { partially evaluated: !qdbus_loadLibDBus()| no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
| 69 | d = 0; never executed (the execution status of this line is deduced): d = 0; | - |
| 70 | return; | 0 |
| 71 | } | - |
| 72 | d = new QDBusConnectionPrivate(this); executed (the execution status of this line is deduced): d = new QDBusConnectionPrivate(this); | - |
| 73 | | - |
| 74 | QObject::connect(d, SIGNAL(newServerConnection(QDBusConnection)), executed (the execution status of this line is deduced): QObject::connect(d, "2""newServerConnection(QDBusConnection)", | - |
| 75 | this, SIGNAL(newConnection(QDBusConnection))); executed (the execution status of this line is deduced): this, "2""newConnection(QDBusConnection)"); | - |
| 76 | | - |
| 77 | QDBusErrorInternal error; executed (the execution status of this line is deduced): QDBusErrorInternal error; | - |
| 78 | d->setServer(q_dbus_server_listen(address.toUtf8().constData(), error), error); executed (the execution status of this line is deduced): d->setServer(q_dbus_server_listen(address.toUtf8().constData(), error), error); | - |
| 79 | } executed: }Execution Count:8 | 8 |
| 80 | | - |
| 81 | /*! | - |
| 82 | Constructs a QDBusServer with the given \a parent. The server will listen | - |
| 83 | for connections in \c {/tmp}. | - |
| 84 | */ | - |
| 85 | QDBusServer::QDBusServer(QObject *parent) | - |
| 86 | : QObject(parent) | - |
| 87 | { | - |
| 88 | const QString address = QLatin1String("unix:tmpdir=/tmp"); never executed (the execution status of this line is deduced): const QString address = QLatin1String("unix:tmpdir=/tmp"); | - |
| 89 | | - |
| 90 | if (!qdbus_loadLibDBus()) { never evaluated: !qdbus_loadLibDBus() | 0 |
| 91 | d = 0; never executed (the execution status of this line is deduced): d = 0; | - |
| 92 | return; | 0 |
| 93 | } | - |
| 94 | d = new QDBusConnectionPrivate(this); never executed (the execution status of this line is deduced): d = new QDBusConnectionPrivate(this); | - |
| 95 | | - |
| 96 | QObject::connect(d, SIGNAL(newServerConnection(QDBusConnection)), never executed (the execution status of this line is deduced): QObject::connect(d, "2""newServerConnection(QDBusConnection)", | - |
| 97 | this, SIGNAL(newConnection(QDBusConnection))); never executed (the execution status of this line is deduced): this, "2""newConnection(QDBusConnection)"); | - |
| 98 | | - |
| 99 | QDBusErrorInternal error; never executed (the execution status of this line is deduced): QDBusErrorInternal error; | - |
| 100 | d->setServer(q_dbus_server_listen(address.toUtf8().constData(), error), error); never executed (the execution status of this line is deduced): d->setServer(q_dbus_server_listen(address.toUtf8().constData(), error), error); | - |
| 101 | } | 0 |
| 102 | | - |
| 103 | /*! | - |
| 104 | Destructs a QDBusServer | - |
| 105 | */ | - |
| 106 | QDBusServer::~QDBusServer() | - |
| 107 | { | - |
| 108 | if (QDBusConnectionManager::instance()) { partially evaluated: QDBusConnectionManager::instance()| yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
| 109 | QMutexLocker locker(&QDBusConnectionManager::instance()->mutex); executed (the execution status of this line is deduced): QMutexLocker locker(&QDBusConnectionManager::instance()->mutex); | - |
| 110 | Q_FOREACH (const QString &name, d->serverConnectionNames) { executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d->serverConnectionNames)> _container_(d->serverConnectionNames); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QString &name = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
| 111 | QDBusConnectionManager::instance()->removeConnection(name); executed (the execution status of this line is deduced): QDBusConnectionManager::instance()->removeConnection(name); | - |
| 112 | } executed: }Execution Count:17 | 17 |
| 113 | d->serverConnectionNames.clear(); executed (the execution status of this line is deduced): d->serverConnectionNames.clear(); | - |
| 114 | } executed: }Execution Count:8 | 8 |
| 115 | } executed: }Execution Count:8 | 8 |
| 116 | | - |
| 117 | /*! | - |
| 118 | Returns true if this QDBusServer object is connected. | - |
| 119 | | - |
| 120 | If it isn't connected, you need to call the constructor again. | - |
| 121 | */ | - |
| 122 | bool QDBusServer::isConnected() const | - |
| 123 | { | - |
| 124 | return d && d->server && q_dbus_server_get_is_connected(d->server); executed: return d && d->server && q_dbus_server_get_is_connected(d->server);Execution Count:17 | 17 |
| 125 | } | - |
| 126 | | - |
| 127 | /*! | - |
| 128 | Returns the last error that happened in this server. | - |
| 129 | | - |
| 130 | This function is provided for low-level code. | - |
| 131 | */ | - |
| 132 | QDBusError QDBusServer::lastError() const | - |
| 133 | { | - |
| 134 | return d->lastError; never executed: return d->lastError; | 0 |
| 135 | } | - |
| 136 | | - |
| 137 | /*! | - |
| 138 | Returns the address this server is associated with. | - |
| 139 | */ | - |
| 140 | QString QDBusServer::address() const | - |
| 141 | { | - |
| 142 | QString addr; executed (the execution status of this line is deduced): QString addr; | - |
| 143 | if (d && d->server) { partially evaluated: d| yes Evaluation Count:18 | no Evaluation Count:0 |
partially evaluated: d->server| yes Evaluation Count:18 | no Evaluation Count:0 |
| 0-18 |
| 144 | char *c = q_dbus_server_get_address(d->server); executed (the execution status of this line is deduced): char *c = q_dbus_server_get_address(d->server); | - |
| 145 | addr = QString::fromUtf8(c); executed (the execution status of this line is deduced): addr = QString::fromUtf8(c); | - |
| 146 | q_dbus_free(c); executed (the execution status of this line is deduced): q_dbus_free(c); | - |
| 147 | } executed: }Execution Count:18 | 18 |
| 148 | | - |
| 149 | return addr; executed: return addr;Execution Count:18 | 18 |
| 150 | } | - |
| 151 | | - |
| 152 | /*! | - |
| 153 | \fn void QDBusServer::newConnection(const QDBusConnection &connection) | - |
| 154 | | - |
| 155 | This signal is emitted when a new client connection \a connection is | - |
| 156 | established to the server. | - |
| 157 | */ | - |
| 158 | | - |
| 159 | QT_END_NAMESPACE | - |
| 160 | | - |
| 161 | #endif // QT_NO_DBUS | - |
| 162 | | - |
| | |