My Project
dbusinterface.cpp
1 /*
2  * This file is part of signon
3  *
4  * Copyright (C) 2011 Nokia Corporation.
5  * Copyright (C) 2011-2016 Canonical Ltd.
6  *
7  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * version 2.1 as published by the Free Software Foundation.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  */
23 
24 #include "dbusinterface.h"
25 #include "debug.h"
26 #include "libsignoncommon.h"
27 
28 #include <climits>
29 
30 using namespace SignOn;
31 
32 static bool connIsP2P(const QDBusConnection &connection)
33 {
34  return connection.name().startsWith(QLatin1String("libsignon-qt"));
35 }
36 
37 DBusInterface::DBusInterface(const QString &service,
38  const QString &path,
39  const char *interface,
40  const QDBusConnection &connection,
41  QObject *parent):
42  /* Use empty service name for p2p connections. This is a workaround for
43  * https://bugreports.qt-project.org/browse/QTBUG-32374
44  */
45  QDBusAbstractInterface(connIsP2P(connection) ? QLatin1String("") : service,
46  path, interface, connection, parent)
47 {
48  setTimeout(INT_MAX);
49 }
50 
51 DBusInterface::~DBusInterface()
52 {
53 }
54 
55 bool DBusInterface::connect(const char *name,
56  QObject *receiver,
57  const char *slot)
58 {
59  return connection().connect(service(), path(), interface(),
60  QLatin1String(name), receiver, slot);
61 }
62