2
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details:
14
# Copyright (C) 2011 Red Hat, Inc.
17
import gobject, sys, dbus
18
from dbus.mainloop.glib import DBusGMainLoop
20
DBusGMainLoop(set_as_default=True)
22
MM_DBUS_SERVICE='org.freedesktop.ModemManager'
23
MM_DBUS_PATH='/org/freedesktop/ModemManager'
24
MM_DBUS_INTERFACE='org.freedesktop.ModemManager'
25
MM_DBUS_INTERFACE_MODEM='org.freedesktop.ModemManager.Modem'
27
def modemAdded(modem_path):
28
proxy = bus.get_object(MM_DBUS_SERVICE, modem_path)
29
modem = dbus.Interface(proxy, dbus_interface=MM_DBUS_INTERFACE_MODEM)
32
bus = dbus.SystemBus()
34
manager_proxy = bus.get_object(MM_DBUS_SERVICE, MM_DBUS_PATH)
35
manager_iface = dbus.Interface(manager_proxy, dbus_interface=MM_DBUS_INTERFACE)
37
# Enable modems that are already known
38
for m in manager_iface.EnumerateDevices():
41
# Listen for new modems
42
manager_iface.connect_to_signal("DeviceAdded", modemAdded)
44
# Start the mainloop and listen
45
loop = gobject.MainLoop()
48
except KeyboardInterrupt: