author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 01:19:32 +0300 | |
changeset 37 | 758a864f9613 |
parent 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtDBus module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "qdbusserver.h" |
|
43 |
#include "qdbusconnection_p.h" |
|
44 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
45 |
#ifndef QT_NO_DBUS |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
46 |
|
0 | 47 |
QT_BEGIN_NAMESPACE |
48 |
||
49 |
/*! |
|
50 |
\class QDBusServer |
|
51 |
\inmodule QtDBus |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
52 |
\internal |
0 | 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 (!qdbus_loadLibDBus()) { |
|
66 |
d = 0; |
|
67 |
return; |
|
68 |
} |
|
69 |
d = new QDBusConnectionPrivate(this); |
|
70 |
||
71 |
if (address.isEmpty()) |
|
72 |
return; |
|
73 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
74 |
QObject::connect(d, SIGNAL(newServerConnection(QDBusConnection)), |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
75 |
this, SIGNAL(newConnection(QDBusConnection))); |
0 | 76 |
|
77 |
// server = q_dbus_server_listen( "unix:tmpdir=/tmp", &error); |
|
78 |
QDBusErrorInternal error; |
|
79 |
d->setServer(q_dbus_server_listen(address.toUtf8().constData(), error), error); |
|
80 |
} |
|
81 |
||
82 |
/*! |
|
83 |
Returns true if this QDBusServer object is connected. |
|
84 |
||
85 |
If it isn't connected, you need to call the constructor again. |
|
86 |
*/ |
|
87 |
bool QDBusServer::isConnected() const |
|
88 |
{ |
|
89 |
return d && d->server && q_dbus_server_get_is_connected(d->server); |
|
90 |
} |
|
91 |
||
92 |
/*! |
|
93 |
Returns the last error that happened in this server. |
|
94 |
||
95 |
This function is provided for low-level code. |
|
96 |
*/ |
|
97 |
QDBusError QDBusServer::lastError() const |
|
98 |
{ |
|
99 |
return d->lastError; |
|
100 |
} |
|
101 |
||
102 |
/*! |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
103 |
Returns the address this server is associated with. |
0 | 104 |
*/ |
105 |
QString QDBusServer::address() const |
|
106 |
{ |
|
107 |
QString addr; |
|
108 |
if (d && d->server) { |
|
109 |
char *c = q_dbus_server_get_address(d->server); |
|
110 |
addr = QString::fromUtf8(c); |
|
111 |
q_dbus_free(c); |
|
112 |
} |
|
113 |
||
114 |
return addr; |
|
115 |
} |
|
116 |
/*! |
|
117 |
\fn void QDBusServer::newConnection(const QDBusConnection &connection) |
|
118 |
||
119 |
This signal is currently not used, but if and when it is |
|
120 |
used, \a connection will be the new connection. |
|
121 |
*/ |
|
122 |
||
123 |
QT_END_NAMESPACE |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
124 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
125 |
#endif // QT_NO_DBUS |