1
# Copyright (C) 2008 Valmantas Paliksa <walmis at balticum-tv dot lt>
2
# Copyright (C) 2008 Tadas Dailyda <tadas at dailyda dot com>
4
# Licensed under the GNU General Public License Version 3
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
1
from blueman.Functions import *
20
2
from blueman.main.Config import Config
21
3
from blueman.bluez.ServiceInterface import ServiceInterface
29
12
class Networking(AppletPlugin):
31
__description__ = _("Manages local network services, like NAP bridges")
34
def on_load(self, applet):
36
self.Signals = SignalTracker()
38
self.Config = Config("network")
39
self.Signals.Handle("gobject", self.Config, "property-changed", self.on_config_changed)
41
self.load_nap_settings()
43
def on_manager_state_changed(self, state):
47
def load_nap_settings(self):
48
dprint("Loading NAP settings")
52
lines = str(excp).splitlines()
53
d = gtk.MessageDialog( None, buttons=gtk.BUTTONS_OK, type=gtk.MESSAGE_ERROR)
54
d.props.text = _("Failed to apply network settings")
55
d.props.secondary_text = lines[-1] + "\n\n"+_("You might not be able to connect to the Bluetooth network via this machine")
60
m.ReloadNetwork(reply_handler=reply, error_handler=err)
63
self.Signals.DisconnectAll()
65
def on_adapter_added(self, path):
68
def update_status(self):
69
self.set_nap(self.Config.props.nap_enable or False)
70
self.set_gn(self.Config.props.gn_enable or False)
73
def on_config_changed(self, config, key, value):
74
if key == "nap_enable":
76
elif key == "gn_enable":
80
def set_nap(self, on):
82
if self.Applet.Manager != None:
83
adapters = self.Applet.Manager.ListAdapters()
84
for adapter in adapters:
85
s = ServiceInterface("org.bluez.NetworkServer", adapter.GetObjectPath(), ["Register", "Unregister"])
87
s.Register("nap", "pan1")
93
#latest bluez does not support gn
95
# dprint("set gn", on)
97
# m.SetGN(on, reply_handler=(lambda *args: None), error_handler=(lambda *args: None))
99
# if self.Applet.Manager != None:
100
# adapters = self.Applet.Manager.ListAdapters()
101
# for adapter in adapters:
102
# s = ServiceInterface("org.bluez.NetworkServer", adapter.GetObjectPath(), ["Register", "Unregister"])
104
# s.Register("gn", "pan0")
14
__description__ = _("Manages local network services, like NAP bridges")
17
def on_load(self, applet):
19
self.Signals = SignalTracker()
21
self.Config = Config("network")
22
self.Signals.Handle("gobject", self.Config, "property-changed", self.on_config_changed)
24
self.load_nap_settings()
26
def on_manager_state_changed(self, state):
30
def load_nap_settings(self):
31
dprint("Loading NAP settings")
37
lines = str(excp).splitlines()
38
d = gtk.MessageDialog(None, buttons=gtk.BUTTONS_OK, type=gtk.MESSAGE_ERROR)
39
d.props.text = _("Failed to apply network settings")
40
d.props.secondary_text = lines[-1] + "\n\n" + _(
41
"You might not be able to connect to the Bluetooth network via this machine")
46
m.ReloadNetwork(reply_handler=reply, error_handler=err)
49
self.Signals.DisconnectAll()
51
def on_adapter_added(self, path):
54
def update_status(self):
55
self.set_nap(self.Config.props.nap_enable or False)
58
def on_config_changed(self, config, key, value):
59
if key == "nap_enable":
63
def set_nap(self, on):
65
if self.Applet.Manager != None:
66
adapters = self.Applet.Manager.ListAdapters()
67
for adapter in adapters:
68
s = ServiceInterface("org.bluez.NetworkServer", adapter.GetObjectPath(), ["Register", "Unregister"])
70
s.Register("nap", "pan1")