[packagekit] Not doing updates when on GPRS

Dan Williams dcbw at redhat.com
Mon Apr 21 19:47:07 PDT 2008


On Mon, 2008-04-21 at 19:52 +0100, Richard Hughes wrote:
> I want to make PackageKit not do updates when I'm on my GRPS connection
> - for this we need to know:

Everything below is for 0.7 trunk >= r3584, since 0.6.x does not support
mobile broadband connections.  You can use check which NM you're using
by trying a dbus method call that's only supported by NM 0.6.x and
seeing if it's implemented or not.

> 1. If the connection is up

Grab the ActiveConnections property of
the /org/freedesktop/NetworkManager object using the D-Bus Properties
interface.  It's an 'ao'.

For each of the active connections there, grab it's 'default' property.
The only one with default = TRUE is the connection you care about, since
it's the one that NM thinks has the route to the internet.

> 2. The type of connection

There are two ways to do this, but I'll just list the easiest one here.

With the ActiveConnection object you got in (1), grab the "Devices"
property using the D-Bus properties interface.  It's also an 'ao'.  For
each device, check the 'DeviceType' property (using the D-Bus Properties
interface again).  If the device type is NM_DEVICE_TYPE_GSM or
NM_DEVICE_TYPE_CDMA (see /usr/include/NetworkManager/NetworkManager.h),
then you are using a mobile broadband connection as your primary
internet connection.

> 3. The throughput of the connection

There's no way to know that yet for mobile broadband connections, since
for many cards you cannot interrogate the modem using AT commands while
connected, because most cards (Sierra and Novatel are the largest
offenders here, but Pantech and others as well) only expose proprietary
interfaces on the secondary USB endpoints, and the secondary endpoints
are the only ones available while the PPP session is happening on the
primary endpoint.  This will get better at some point though.

> And we need a metric to sum this up as a:
> 
> [X] Don't update when on slow connections
> or
> [X] Don't update when on dial up connections
> 
> I guess we can use libnm_glib for this, as we already get the
> connection "up/down" status like that. Other ideas welcome.

Since PK is python, you're much better off using Python for this I
think.  It should be drop-dead-easy to do this in Python using
dbus-python.

Dan





More information about the PackageKit mailing list