dbusinterface.cpp
00001 /*
00002  * This file is part of signon
00003  *
00004  * Copyright (C) 2011 Nokia Corporation.
00005  * Copyright (C) 2011-2015 Canonical Ltd.
00006  *
00007  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public License
00011  * version 2.1 as published by the Free Software Foundation.
00012  *
00013  * This library is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00021  * 02110-1301 USA
00022  */
00023 
00024 #include "dbusinterface.h"
00025 #include "debug.h"
00026 #include "libsignoncommon.h"
00027 
00028 #include <climits>
00029 
00030 using namespace SignOn;
00031 
00032 static bool connIsP2P(const QDBusConnection &connection)
00033 {
00034     return connection.name().startsWith(QLatin1String("libsignon-qt"));
00035 }
00036 
00037 DBusInterface::DBusInterface(const QString &service,
00038                              const QString &path,
00039                              const char *interface,
00040                              const QDBusConnection &connection,
00041                              QObject *parent):
00042     /* Use empty service name for p2p connections. This is a workaround for
00043      * https://bugreports.qt-project.org/browse/QTBUG-32374
00044      */
00045     QDBusAbstractInterface(connIsP2P(connection) ? QLatin1String("") : service,
00046                            path, interface, connection, parent)
00047 {
00048     setTimeout(INT_MAX);
00049 }
00050 
00051 DBusInterface::~DBusInterface()
00052 {
00053 }
00054 
00055 bool DBusInterface::connect(const char *name,
00056                             QObject *receiver,
00057                             const char *slot)
00058 {
00059     return connection().connect(service(), path(), interface(),
00060                                 QLatin1String(name), receiver, slot);
00061 }
00062