~ubuntu-branches/ubuntu/lucid/sabayon/lucid

« back to all changes in this revision

Viewing changes to admin-tool/lockdown/safeprotocols.py

  • Committer: Bazaar Package Importer
  • Author(s): Scott Balneaves
  • Date: 2009-12-28 16:58:21 UTC
  • mfrom: (1.1.16 upstream)
  • Revision ID: james.westby@ubuntu.com-20091228165821-38riqcxr41abmelj
Tags: 2.29.5~rc1-0ubuntu1
* New upstream release
  - Depend on Pessulus
  - Added manual
  - Fixed several crasher bugs
  - Added apply by group
  - Symlinks now saved in zipfile
* debian
  - Updated deps in control
  - removed sabayon.8, sabayon-apply.8, install.manpages (upstream man)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# vim: set ts=4 sw=4 et:
2
 
 
3
 
#
4
 
# Copyright (C) 2005 Vincent Untz <vuntz@gnome.org>
5
 
#
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 2 of the License, or
9
 
# (at your option) any later version.
10
 
#
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.
15
 
#
16
 
# You should have received a copy of the GNU General Public License
17
 
# along with this program; if not, write to the Free Software
18
 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
19
 
#
20
 
 
21
 
import gconf
22
 
import gtk
23
 
 
24
 
try:
25
 
    set
26
 
except:
27
 
    from sets import Set as set
28
 
 
29
 
from sabayon import errors
30
 
from sabayon import debuglog
31
 
import globalvar
32
 
import simpleeditabletreeview
33
 
 
34
 
# Note that the idea is to only have one toggle to set/unset mandatory settings
35
 
# for this key and the disable_unsafe_protocols key.
36
 
 
37
 
class PessulusSafeProtocols:
38
 
    def __init__ (self, lockdownbutton, treeview, addbutton, editbutton, removebutton):
39
 
        self.notify_id = None
40
 
        self.key = "/apps/epiphany/lockdown/additional_safe_protocols"
41
 
        self.safe_protocols = None
42
 
        self.sensitive = True
43
 
 
44
 
        self.lockdownbutton = lockdownbutton
45
 
        self.lockdownbutton.connect ("toggled",
46
 
                                     self.__on_lockdownbutton_toggled)
47
 
 
48
 
        treeview.connect ("destroy", self.__on_destroyed)
49
 
        self.simpleeditabletreeview = simpleeditabletreeview.PessulusSimpleEditableTreeview (treeview, addbutton, editbutton, removebutton)
50
 
        self.simpleeditabletreeview.connect ("changed",
51
 
                                             self.__on_treeview_changed)
52
 
 
53
 
        (list, mandatory) = globalvar.applier.get_list (self.key,
54
 
                                                        gconf.VALUE_STRING)
55
 
        self.safe_protocols = set (list)
56
 
        self.__update_simpleeditabletreeview ()
57
 
        self.lockdownbutton.set (mandatory)
58
 
        self.notify_id = globalvar.applier.notify_add (self.key,
59
 
                                                       self.__on_notified)
60
 
 
61
 
    def set_sensitive (self, sensitive):
62
 
        self.sensitive = sensitive
63
 
        self.__update_sensitivity ()
64
 
 
65
 
    @errors.checked_callback (debuglog.DEBUG_LOG_DOMAIN_PESSULUS)
66
 
    def __on_notified (self, data):
67
 
        (list, mandatory) = globalvar.applier.get_list (self.key,
68
 
                                                        gconf.VALUE_STRING)
69
 
        gconf_set = set (list)
70
 
        if gconf_set != self.safe_protocols:
71
 
            self.safe_protocols = gconf_set
72
 
            self.__update_simpleeditabletreeview ()
73
 
        if mandatory != self.lockdownbutton.get ():
74
 
            self.lockdownbutton.set (mandatory)
75
 
 
76
 
    @errors.checked_callback (debuglog.DEBUG_LOG_DOMAIN_USER)
77
 
    def __on_lockdownbutton_toggled (self, lockdownbutton, mandatory):
78
 
        globalvar.applier.set_list (self.key, gconf.VALUE_STRING,
79
 
                                    list (self.safe_protocols),
80
 
                                    mandatory)
81
 
 
82
 
    @errors.checked_callback (debuglog.DEBUG_LOG_DOMAIN_USER)
83
 
    def __on_treeview_changed (self, simpleeditabletreeview, new_set):
84
 
        if new_set != self.safe_protocols:
85
 
            self.safe_protocols = new_set.copy ()
86
 
            globalvar.applier.set_list (self.key, gconf.VALUE_STRING,
87
 
                                        list (self.safe_protocols),
88
 
                                        self.lockdownbutton.get ())
89
 
 
90
 
    def __update_sensitivity (self):
91
 
        if globalvar.applier:
92
 
            sensitive = self.sensitive and globalvar.applier.key_is_writable (self.key)
93
 
        else:
94
 
            sensitive = self.sensitive
95
 
 
96
 
        self.simpleeditabletreeview.set_sensitive (sensitive)
97
 
 
98
 
    def __update_simpleeditabletreeview (self):
99
 
        self.__update_sensitivity ()
100
 
        self.simpleeditabletreeview.update_set (self.safe_protocols)
101
 
 
102
 
    @errors.checked_callback (debuglog.DEBUG_LOG_DOMAIN_PESSULUS)
103
 
    def __on_destroyed (self, treeview):
104
 
        if self.notify_id:
105
 
            if globalvar.applier:
106
 
                globalvar.applier.notify_remove (self.notify_id)
107
 
            self.notify_id = None