7 from networkmanager
.applet
.service
import UserSettings
8 from networkmanager
.applet
.service
.mkconmap
import *
10 # must be set before we ask for signals
11 from dbus
.mainloop
.glib
import DBusGMainLoop
12 DBusGMainLoop(set_as_default
=True)
15 loop
= gobject
.MainLoop()
17 from optparse
import OptionParser
19 op
= OptionParser(version
="%prog " + VERSION
)
21 op
.add_option("--unprotected",
22 action
="store_true", default
=False,
23 help="network does not require a key")
24 op
.add_option("--wep-hex",
26 help="use this WEP key of 26 hex digits")
27 op
.add_option("--wep-pass",
29 help="use this WEP passphrase")
30 #op.add_option("--wpa-psk-hex",
32 # help="use this WPA key of 64 hex digits")
33 op
.add_option("--wpa-pass",
35 help="use this WPA passphrase")
37 (options
, args
) = op
.parse_args()
40 bus
= dbus
.SystemBus()
42 def service_pid(name
):
43 DBS
= 'org.freedesktop.DBus'
45 dbo
= bus
.get_object(DBS
, '/')
46 dbi
= dbus
.Interface(dbo
, DBI
)
47 owner
= dbi
.GetNameOwner(name
)
48 pid
= dbi
.GetConnectionUnixProcessID(owner
)
51 NMUS
= "org.freedesktop.NetworkManagerUserSettings"
52 brn
= bus
.request_name(NMUS
, _dbus_bindings
.NAME_FLAG_DO_NOT_QUEUE
)
53 if brn
== _dbus_bindings
.REQUEST_NAME_REPLY_EXISTS
:
54 print "Could not provide settings service, another applet is running (pid %s)" % service_pid(NMUS
)
56 us
= UserSettings("/org/freedesktop/NetworkManagerSettings", [])
59 if options
.unprotected
:
60 c
= mkconmap_wifi(ssid
)
62 if options
.wep_hex
!= None:
63 c
= mkconmap_wep(ssid
, options
.wep_hex
)
65 if options
.wep_pass
!= None:
66 c
= mkconmap_wep_pass(ssid
, options
.wep_pass
)
68 # if options.wpa_psk_hex != None:
69 # c = mkconmap_psk(ssid, options.wpa_psk_hex)
71 if options
.wpa_pass
!= None:
72 c
= mkconmap_psk(ssid
, options
.wpa_pass
)
76 print "Entering mainloop"
78 except KeyboardInterrupt: