[nanny] Added a new app for manage the blacklists (install, remove and update)
- From: Cesar Garcia Tapia <ctapia src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nanny] Added a new app for manage the blacklists (install, remove and update)
- Date: Thu, 4 Feb 2010 14:53:20 +0000 (UTC)
commit 8a94b66724bd7f242d0753e3e2261cc6b0e1e577
Author: Cesar Garcia Tapia <cesar garcia tapia openshine com>
Date: Thu Feb 4 15:52:35 2010 +0100
Added a new app for manage the blacklists (install, remove and update)
client/common/src/DBusClient.py | 4 +-
client/gnome/admin/Makefile.am | 4 +-
client/gnome/admin/NannyBlacklistManager | 37 ++++
client/gnome/admin/data/glade/Makefile.am | 4 +-
client/gnome/admin/data/glade/nbm_pbl_dialog.glade | 99 +++++++++++
.../admin/data/glade/nbm_pbl_edit_dialog.glade | 73 ++++++++
client/gnome/admin/src/BlacklistManager.py | 187 ++++++++++++++++++++
client/gnome/admin/src/Makefile.am | 1 +
client/gnome/admin/src/__init__.py.in | 1 +
po/POTFILES.in | 3 +
10 files changed, 408 insertions(+), 5 deletions(-)
---
diff --git a/client/common/src/DBusClient.py b/client/common/src/DBusClient.py
index e07292a..7cc8875 100644
--- a/client/common/src/DBusClient.py
+++ b/client/common/src/DBusClient.py
@@ -136,8 +136,8 @@ class DBusClient(gobject.GObject):
def remove_custom_filter (self, filter_id, reply_handler, error_handler):
return self.nanny_wcf.RemoveCustomFilter (filter_id, reply_handler=reply_handler, error_handler=error_handler, timeout=2000000)
- def add_pkg_filter (self, name, description, path):
- return self.nanny_wcf.AddPkgFilter(name, description, path)
+ def add_pkg_filter (self, name):
+ return self.nanny_wcf.AddPkgFilter(name)
def remove_pkg_filter (self, pkg_id):
return self.nanny_wcf.RemovePkgFilter(pkg_id)
diff --git a/client/gnome/admin/Makefile.am b/client/gnome/admin/Makefile.am
index c6293e9..60fb01b 100644
--- a/client/gnome/admin/Makefile.am
+++ b/client/gnome/admin/Makefile.am
@@ -1,5 +1,5 @@
SUBDIRS=data src
-sbin_SCRIPTS = NannyAdminConsole
+sbin_SCRIPTS = NannyAdminConsole NannyBlacklistManager
-EXTRA_DIST = NannyAdminConsole
+EXTRA_DIST = NannyAdminConsole NannyBlacklistManager
diff --git a/client/gnome/admin/NannyBlacklistManager b/client/gnome/admin/NannyBlacklistManager
new file mode 100644
index 0000000..0bda49b
--- /dev/null
+++ b/client/gnome/admin/NannyBlacklistManager
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+# Copyright (C) 2009 Roberto Majadas, Cesar Garcia, Luis de Bethencourt
+# <openshine.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+# USA
+
+import syslog
+import gtk
+import gettext
+import __builtin__
+
+import nanny.client.gnome.admin
+
+if __name__ == '__main__':
+ #parser = OptionParser()
+ #parser.add_option("-p", "--pid-file", dest="pid_file", help="pid File", metavar="PID_FILE")
+ #parser.add_option("--no-daemon",action="store_false", dest="daemon", default=True, help="Don't create daemon")
+ #(options, args) = parser.parse_args()
+
+ __builtin__._ = gettext.gettext
+
+ syslog.syslog(syslog.LOG_INFO,"Booting nanny blacklist manager")
+
+ nanny_blacklist_manager = nanny.client.gnome.admin.BlacklistManager()
diff --git a/client/gnome/admin/data/glade/Makefile.am b/client/gnome/admin/data/glade/Makefile.am
index fead086..b1e4b1a 100644
--- a/client/gnome/admin/data/glade/Makefile.am
+++ b/client/gnome/admin/data/glade/Makefile.am
@@ -1,6 +1,8 @@
gladedir = $(datadir)/nanny/client/gnome/admin/glade
glade_DATA = nanny_admin_console.glade \
nac_wcf_edit_dialog.glade \
- nac_wcf_dialog.glade
+ nac_wcf_dialog.glade \
+ nbm_pbl_dialog.glade \
+ nbm_pbl_edit_dialog.glade
EXTRA_DIST=$(glade_DATA)
diff --git a/client/gnome/admin/data/glade/nbm_pbl_dialog.glade b/client/gnome/admin/data/glade/nbm_pbl_dialog.glade
new file mode 100644
index 0000000..ddcf982
--- /dev/null
+++ b/client/gnome/admin/data/glade/nbm_pbl_dialog.glade
@@ -0,0 +1,99 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkWindow" id="window1">
+ <child>
+ <object class="GtkAlignment" id="nbm_alignment">
+ <property name="visible">True</property>
+ <property name="top_padding">5</property>
+ <property name="bottom_padding">5</property>
+ <property name="left_padding">5</property>
+ <property name="right_padding">5</property>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="spacing">5</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">etched-in</property>
+ <child>
+ <object class="GtkTreeView" id="nbm_blacklist_treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_visible">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVButtonBox" id="vbuttonbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">5</property>
+ <property name="layout_style">start</property>
+ <child>
+ <object class="GtkButton" id="nbm_blacklist_import_button">
+ <property name="label">Import...</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">image1</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="nbm_blacklist_edit_button">
+ <property name="label">gtk-edit</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="nbm_blacklist_remove_button">
+ <property name="label">gtk-remove</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="stock">gtk-jump-to</property>
+ </object>
+</interface>
diff --git a/client/gnome/admin/data/glade/nbm_pbl_edit_dialog.glade b/client/gnome/admin/data/glade/nbm_pbl_edit_dialog.glade
new file mode 100644
index 0000000..7504948
--- /dev/null
+++ b/client/gnome/admin/data/glade/nbm_pbl_edit_dialog.glade
@@ -0,0 +1,73 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkWindow" id="window1">
+ <child>
+ <object class="GtkAlignment" id="nbm_main_alignment">
+ <property name="visible">True</property>
+ <property name="top_padding">10</property>
+ <property name="bottom_padding">10</property>
+ <property name="left_padding">10</property>
+ <property name="right_padding">10</property>
+ <child>
+ <object class="GtkTable" id="nbm_main_table">
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">5</property>
+ <property name="row_spacing">10</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Name:</property>
+ </object>
+ <packing>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Description:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="nbm_name_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="nbm_description_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/client/gnome/admin/src/BlacklistManager.py b/client/gnome/admin/src/BlacklistManager.py
new file mode 100644
index 0000000..34ed45b
--- /dev/null
+++ b/client/gnome/admin/src/BlacklistManager.py
@@ -0,0 +1,187 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2009 Junta de Andalucia
+#
+# Authors:
+# Roberto Majadas <roberto.majadas at openshine.com>
+# Cesar Garcia Tapia <cesar.garcia.tapia at openshine.com>
+# Luis de Bethencourt <luibg at openshine.com>
+# Pablo Vieytes <pvieytes at openshine.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+# USA
+
+import os
+
+import gtk
+import pango
+import gobject
+
+import nanny
+
+class BlacklistManager:
+ def __init__ (self):
+ self.dialog = gtk.Dialog (title=_("Blacklist Filter Configuration"), buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
+
+ nanny.client.common.Utils.glade_magic (self,
+ glade_file = os.path.join (nanny.client.gnome.admin.glade_files_dir, "nbm_pbl_dialog.glade"),
+ prefix = "nbm")
+
+ self.dialog.set_property("icon-name", "nanny")
+ self.dbus_client = nanny.client.common.DBusClient ()
+
+ self.alignment.unparent ()
+ self.dialog.get_content_area().add (self.alignment)
+
+ self.blacklist_import_button.connect ('clicked', self.__on_blacklist_import_button_clicked)
+ self.blacklist_edit_button.connect ('clicked', self.__on_blacklist_edit_button_clicked)
+ self.blacklist_remove_button.connect ('clicked', self.__on_blacklist_remove_button_clicked)
+
+ self.__selected_blacklist = None
+
+ self.__init_treeview (self.blacklist_treeview)
+ self.__fill_treeview ()
+
+ selection = self.blacklist_treeview.get_selection()
+ selection.connect ('changed', self.__on_blacklist_selection_changed)
+ self.__on_blacklist_selection_changed (selection)
+
+ self.dialog.resize (700, 460)
+
+ self.dialog.run ()
+ self.dialog.destroy()
+
+ def __init_treeview (self, treeview):
+ base_id = 1
+ for field in ["id", "name"]:
+ col = gtk.TreeViewColumn(field)
+ treeview.append_column(col)
+ cell = gtk.CellRendererText()
+ cell.set_property("ellipsize", pango.ELLIPSIZE_END)
+ col.pack_start(cell, True)
+ col.add_attribute(cell, 'markup', base_id)
+ if field != "id":
+ col.set_visible (True)
+ else:
+ col.set_visible (False)
+
+ base_id = base_id + 1
+
+ store = gtk.ListStore (gobject.TYPE_BOOLEAN,
+ gobject.TYPE_STRING,
+ gobject.TYPE_STRING)
+
+ treeview.set_model (store)
+
+ def __fill_treeview (self):
+ model = self.blacklist_treeview.get_model()
+ model.clear()
+
+ filters = self.dbus_client.list_pkg_filters ()
+ for filter_id, read_only in filters:
+ filter_name, filter_description = self.dbus_client.get_pkg_filter_metadata(filter_id)
+
+ if read_only:
+ model.append ((read_only, filter_id, _("<b>%s (Read only)</b>\n %s") % (filter_name, filter_description)))
+ else:
+ model.append ((read_only, filter_id, "<b>%s</b>\n %s" % (filter_name, filter_description)))
+
+ def __on_blacklist_import_button_clicked (self, widget, data=None):
+ file_selection_dialog = gtk.FileChooserDialog (_("Select file to import"), self.dialog,
+ buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
+ gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
+ file_selection_dialog.set_select_multiple (False)
+
+ file_filter = gtk.FileFilter ()
+ file_filter.add_pattern ("*.nbl")
+
+ file_selection_dialog.set_filter (file_filter)
+ response = file_selection_dialog.run()
+
+ if response == gtk.RESPONSE_ACCEPT:
+ filename = file_selection_dialog.get_filename()
+ result = self.dbus_client.add_pkg_filter (filename)
+
+ if result:
+ self.__fill_treeview ()
+ else:
+ d = gtk.MessageDialog(None, gtk.DIALOG_MODAL, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK)
+ d.set_property("icon-name", "nanny")
+ d.set_markup(_("<b>Error importing blacklist file</b>"))
+ d.format_secondary_markup(_("Some error has occured importing the blacklist file."))
+ d.run()
+ d.destroy()
+
+ file_selection_dialog.destroy()
+
+ def __on_blacklist_edit_button_clicked (self, widget, data=None):
+ edit_dialog = gtk.Dialog (title=_("Blacklist Filter Configuration"),
+ buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
+ gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
+
+ nanny.client.common.Utils.glade_magic (edit_dialog,
+ glade_file = os.path.join (nanny.client.gnome.admin.glade_files_dir, "nbm_pbl_edit_dialog.glade"),
+ prefix = "nbm")
+
+ edit_dialog.main_alignment.unparent()
+ edit_dialog.get_content_area().add (edit_dialog.main_alignment)
+
+ name, description = self.dbus_client.get_pkg_filter_metadata (self.__selected_blacklist)
+ edit_dialog.name_entry.set_text (name)
+ edit_dialog.description_entry.set_text (description)
+
+ response = edit_dialog.run()
+
+ if response == gtk.RESPONSE_ACCEPT:
+ name = edit_dialog.name_entry.get_text ()
+ description = edit_dialog.description_entry.get_text ()
+ self.dbus_client.set_pkg_filter_metadata (self.__selected_blacklist, name, description)
+ self.__fill_treeview ()
+
+ edit_dialog.destroy()
+
+ def __on_blacklist_remove_button_clicked (self, widget, data=None):
+ if self.__selected_blacklist == None:
+ return
+
+ d = gtk.MessageDialog(None, gtk.DIALOG_MODAL, type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_OK_CANCEL)
+ d.set_property("icon-name", "nanny")
+ d.set_markup(_("<b>Are you sure you want to delete this blacklist?</b>"))
+ d.format_secondary_markup(_("This action will remove all the user configuration linked to the blacklist."))
+ response = d.run()
+ if response == gtk.RESPONSE_OK:
+ self.dbus_client.remove_pkg_filter (self.__selected_blacklist)
+ self.__fill_treeview ()
+
+ d.destroy()
+
+ def __on_blacklist_selection_changed (self, selection, data=None):
+ if selection.count_selected_rows () > 0:
+ model, itera = selection.get_selected ()
+ self.__selected_blacklist = model.get_value (itera, 1)
+ read_only = model.get_value (itera, 0)
+
+ if read_only:
+ self.blacklist_edit_button.set_sensitive (False)
+ self.blacklist_remove_button.set_sensitive (False)
+ else:
+ self.blacklist_edit_button.set_sensitive (True)
+ self.blacklist_remove_button.set_sensitive (True)
+
+ else:
+ self.blacklist_edit_button.set_sensitive (False)
+ self.blacklist_remove_button.set_sensitive (False)
+ self.__selected_blacklist = None
diff --git a/client/gnome/admin/src/Makefile.am b/client/gnome/admin/src/Makefile.am
index f4090a3..fee5fca 100644
--- a/client/gnome/admin/src/Makefile.am
+++ b/client/gnome/admin/src/Makefile.am
@@ -2,4 +2,5 @@ uilibdir = $(pythondir)/nanny/client/gnome/admin
uilib_PYTHON = __init__.py \
AdminConsole.py \
ConfigureProxyDialog.py \
+ BlacklistManager.py \
ScheduleCalendar.py
diff --git a/client/gnome/admin/src/__init__.py.in b/client/gnome/admin/src/__init__.py.in
index ed489b8..ada67b9 100644
--- a/client/gnome/admin/src/__init__.py.in
+++ b/client/gnome/admin/src/__init__.py.in
@@ -25,6 +25,7 @@ import gettext
from AdminConsole import AdminConsole
from ConfigureProxyDialog import ConfigureProxyDialog
from ScheduleCalendar import ScheduleCalendar
+from BlacklistManager import BlacklistManager
share_files_dir= os.path.join("@prefix@","share/","nanny/client/gnome/admin/")
glade_files_dir= os.path.join(share_files_dir,"glade/")
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 20128cb..b45d7b3 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -6,10 +6,13 @@ client/common/src/__init__.py
client/gnome/admin/data/glade/nanny_admin_console.glade
client/gnome/admin/data/glade/nac_wcf_edit_dialog.glade
client/gnome/admin/data/glade/nac_wcf_dialog.glade
+client/gnome/admin/data/glade/nbm_pbl_dialog.glade
+client/gnome/admin/data/glade/nbm_pbl_edit_dialog.glade
client/gnome/admin/src/__init__.py.in
client/gnome/admin/src/ScheduleCalendar.py
client/gnome/admin/src/ConfigureProxyDialog.py
client/gnome/admin/src/AdminConsole.py
+client/gnome/admin/src/BlacklistManager.py
client/gnome/systray/src/__init__.py.in
client/gnome/systray/src/SystrayNanny.py
client/gnome/__init__.py
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]