1
/***************************************************************************
3
* knetworkmanager-device.cpp - A NetworkManager frontend for KDE
5
* Copyright (C) 2005, 2006 Novell, Inc.
7
* Author: Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>
8
* Will Stephenson <wstephenson@suse.de>, <wstephenson@kde.org>
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
**************************************************************************/
26
#include "knetworkmanager.h"
27
#include "knetworkmanager-hal_device_proxy.h"
30
#include <qhostaddress.h>
32
class HalDeviceProxyPrivate
35
HalDeviceProxyPrivate() {}
36
~HalDeviceProxyPrivate() {}
38
void getHalProperty (const QCString& udi, const QCString& property, QCString& result);
43
HalDeviceProxy::HalDeviceProxy (const QString & udi)
45
d = new HalDeviceProxyPrivate;
49
HalDeviceProxy::~HalDeviceProxy ()
55
HalDeviceProxy::getBustype () const
57
QCString device_udi = d->udi.utf8();
58
QCString parent_udi = "";
59
QCString subsystem = "";
61
d->getHalProperty (device_udi, "info.parent", parent_udi);
62
d->getHalProperty (parent_udi, "linux.subsystem", subsystem);
64
if (QString::compare (subsystem, "pci") == 0)
66
else if (QString::compare (subsystem, "usb") == 0)
68
else if (QString::compare (subsystem, "pcmcia") == 0)
75
HalDeviceProxy::getProduct () const
81
HalDeviceProxy::getVendor () const
87
HalDeviceProxyPrivate::getHalProperty (const QCString& udi, const QCString& property, QCString& result)
89
//FIXME: convert to qt3-dbus-api
91
DBusConnection* con = _ctx->getDBus ()->getConnection ();
92
LibHalContext* hal_ctx = NULL;
93
char* prop_val = NULL;
95
if (!con || !property) {
99
if (!dbus_bus_name_has_owner (con, "org.freedesktop.Hal", NULL)) {
100
printf ("Error: HAL seems not to be running.\n");
104
hal_ctx = libhal_ctx_new ();
106
if (!libhal_ctx_set_dbus_connection (hal_ctx, con)) {
110
if (!libhal_ctx_init (hal_ctx, NULL)) {
114
prop_val = libhal_device_get_property_string (hal_ctx, udi, property, NULL);
116
libhal_free_string (prop_val);
119
libhal_ctx_shutdown (hal_ctx, NULL);
120
libhal_ctx_free (hal_ctx);
126
#include "knetworkmanager-hal_device_proxy.moc"