~ubuntu-branches/ubuntu/oneiric/knetworkmanager/oneiric

« back to all changes in this revision

Viewing changes to knetworkmanager/src/knetworkmanager-hal_device_proxy.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-07-14 14:05:44 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080714140544-yjhxgrdwartk3kx7
Tags: 1:0.7svn830754-0ubuntu1
New upstream snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *
 
3
 * knetworkmanager-device.cpp - A NetworkManager frontend for KDE 
 
4
 *
 
5
 * Copyright (C) 2005, 2006 Novell, Inc.
 
6
 *
 
7
 * Author: Timo Hoenig     <thoenig@suse.de>, <thoenig@nouse.net>
 
8
 *         Will Stephenson <wstephenson@suse.de>, <wstephenson@kde.org>
 
9
 *
 
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.
 
14
 *
 
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.
 
19
 * 
 
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
 
23
 *
 
24
 **************************************************************************/
 
25
 
 
26
#include "knetworkmanager.h"
 
27
#include "knetworkmanager-hal_device_proxy.h"
 
28
 
 
29
#include <kdebug.h>
 
30
#include <qhostaddress.h>
 
31
 
 
32
class HalDeviceProxyPrivate
 
33
{
 
34
public:
 
35
        HalDeviceProxyPrivate() {}
 
36
        ~HalDeviceProxyPrivate() {}
 
37
 
 
38
        void getHalProperty (const QCString& udi, const QCString& property, QCString& result);
 
39
 
 
40
        QString      udi;
 
41
};
 
42
 
 
43
HalDeviceProxy::HalDeviceProxy (const QString & udi)
 
44
{
 
45
        d = new HalDeviceProxyPrivate;
 
46
        d->udi = udi;
 
47
}
 
48
 
 
49
HalDeviceProxy::~HalDeviceProxy ()
 
50
{
 
51
        delete d;
 
52
}
 
53
 
 
54
bustype
 
55
HalDeviceProxy::getBustype () const
 
56
{
 
57
        QCString device_udi = d->udi.utf8();
 
58
        QCString parent_udi = "";
 
59
        QCString subsystem  = "";
 
60
 
 
61
        d->getHalProperty (device_udi, "info.parent", parent_udi);
 
62
        d->getHalProperty (parent_udi, "linux.subsystem", subsystem);
 
63
        
 
64
        if (QString::compare (subsystem, "pci") == 0)
 
65
                return BUS_PCI;
 
66
        else if (QString::compare (subsystem, "usb") == 0)
 
67
                return BUS_USB;
 
68
        else if (QString::compare (subsystem, "pcmcia") == 0)
 
69
                return BUS_PCMCIA;
 
70
        else
 
71
                return BUS_UNKNOWN;
 
72
}
 
73
 
 
74
QString
 
75
HalDeviceProxy::getProduct () const
 
76
{
 
77
        return "";
 
78
}
 
79
 
 
80
QString
 
81
HalDeviceProxy::getVendor () const
 
82
{
 
83
        return "";
 
84
}
 
85
 
 
86
void
 
87
HalDeviceProxyPrivate::getHalProperty (const QCString& udi, const QCString& property, QCString& result)
 
88
{
 
89
//FIXME: convert to qt3-dbus-api
 
90
/*
 
91
        DBusConnection* con      = _ctx->getDBus ()->getConnection ();
 
92
        LibHalContext*  hal_ctx  = NULL;
 
93
        char*           prop_val = NULL;
 
94
 
 
95
        if (!con || !property) {
 
96
                goto out;
 
97
        }
 
98
 
 
99
        if (!dbus_bus_name_has_owner (con, "org.freedesktop.Hal", NULL)) {
 
100
                printf ("Error: HAL seems not to be running.\n");
 
101
                goto out;
 
102
        }
 
103
        
 
104
        hal_ctx = libhal_ctx_new ();
 
105
 
 
106
        if (!libhal_ctx_set_dbus_connection (hal_ctx, con)) {
 
107
                goto out;
 
108
        }
 
109
 
 
110
        if (!libhal_ctx_init (hal_ctx, NULL)) {
 
111
                goto out;
 
112
        }
 
113
 
 
114
        prop_val = libhal_device_get_property_string (hal_ctx, udi, property, NULL);
 
115
        result = prop_val;
 
116
        libhal_free_string (prop_val);
 
117
out:
 
118
        if (hal_ctx) {
 
119
                libhal_ctx_shutdown (hal_ctx, NULL);
 
120
                libhal_ctx_free (hal_ctx);
 
121
        }
 
122
*/
 
123
        return;
 
124
}
 
125
 
 
126
#include "knetworkmanager-hal_device_proxy.moc"