This is the patch for umit plugins integration.
The diff only contains modification for common files.
Waiting for approval to commit.
--
Best regards,
Francesco Piccinno
Property changes on: source-plugins
___________________________________________________________________
Added: svn:ignore
+ *.pyc
*.ump
*~
Property changes on: source-plugins/tray-icon
___________________________________________________________________
Added: svn:ignore
+ *.pyc
*.ump
*~
Property changes on: source-plugins/tray-icon/dist
___________________________________________________________________
Added: svn:ignore
+ *.pyc
*.ump
*~
Property changes on: source-plugins/tray-icon/sources
___________________________________________________________________
Added: svn:ignore
+ *.pyc
*.ump
*~
Property changes on: source-plugins/system-info-consumer
___________________________________________________________________
Added: svn:ignore
+ *.pyc
*.ump
*~
Property changes on: source-plugins/system-info-consumer/dist
___________________________________________________________________
Added: svn:ignore
+ *.pyc
*.ump
*~
Property changes on: source-plugins/system-info-consumer/sources
___________________________________________________________________
Added: svn:ignore
+ *.pyc
*.ump
*~
Property changes on: source-plugins/dummy-working
___________________________________________________________________
Added: svn:ignore
+ *.pyc
*.ump
*~
Property changes on: source-plugins/dummy-working/dist
___________________________________________________________________
Added: svn:ignore
+ *.pyc
*.ump
*~
Property changes on: source-plugins/dummy-working/sources
___________________________________________________________________
Added: svn:ignore
+ *.pyc
*.ump
*~
Property changes on: source-plugins/system-info
___________________________________________________________________
Added: svn:ignore
+ *.pyc
*.ump
*~
Property changes on: source-plugins/system-info/dist
___________________________________________________________________
Added: svn:ignore
+ *.pyc
*.ump
*~
Property changes on: source-plugins/system-info/sources
___________________________________________________________________
Added: svn:ignore
+ *.pyc
*.ump
*~
Index: umitGUI/ScanHostsView.py
===================================================================
--- umitGUI/ScanHostsView.py (revision 3791)
+++ umitGUI/ScanHostsView.py (working copy)
@@ -26,6 +26,8 @@
from higwidgets.higboxes import HIGVBox
from umitCore.I18N import _
+from umitPlugin.Engine import PluginEngine
+
SCANNING = _("Scanning")
class ScanHostsView(HIGVBox, object):
@@ -46,6 +48,8 @@
self.host_view.show_all()
self.service_view.show_all()
+
+ PluginEngine().core.emit('ScanHostsView-created', self)
def _create_widgets(self):
# Mode buttons
Index: umitGUI/App.py
===================================================================
--- umitGUI/App.py (revision 3791)
+++ umitGUI/App.py (working copy)
@@ -31,6 +31,7 @@
from umitCore.I18N import _
from umitCore.UmitLogging import log
+from umitPlugin.Engine import PluginEngine
# Script found at
http://www.py2exe.org/index.cgi/HowToDetermineIfRunningFromExe
import imp
@@ -45,7 +46,8 @@
class App:
def __init__(self, args=sys.argv):
- pass
+ # Initialite the PluginEngine
+ PluginEngine()
def __parse_cmd_line(self):
pass
Index: umitGUI/Icons.py
===================================================================
--- umitGUI/Icons.py (revision 3791)
+++ umitGUI/Icons.py (working copy)
@@ -52,6 +52,11 @@
'vl_4',
'vl_5')
+plugins_icons = (
+ 'extension',
+ 'paths'
+)
+
pixmap_path = Path.pixmaps_dir
if pixmap_path:
# This is a generator that returns file names for pixmaps in the order they
@@ -61,6 +66,17 @@
yield '%s_%s.png' % (icon_name, size)
iconfactory = gtk.IconFactory()
+ for icon_name in plugins_icons:
+ for type, size in (('small', 16), ('normal', 32)):
+ key = '%s_%s' % (icon_name, type)
+ try:
+ pixbuf = gtk.gdk.pixbuf_new_from_file(
+ os.path.join(pixmap_path, "%s-%d.png" % (icon_name, size))
+ )
+ iconfactory.add(key, gtk.IconSet(pixbuf))
+ except gobject.GError:
+ continue
+
for icon_name in icon_names:
for type, size in (('icon', '32'), ('logo', '75')):
key = '%s_%s' % (icon_name, type)
@@ -150,3 +166,22 @@
return 'vl_4_logo'
else:
return 'vl_5_logo'
+
+def get_pixbuf(stock_id, w=None, h=None):
+ "Get the pixbuf for a stock item defined in icons"
+
+ name, size = stock_id.split("_")
+
+ if size == "small":
+ size = 16
+ elif size == "normal":
+ size = 32
+ else:
+ raise Exception("Could not determine the pixel size")
+
+ fname = os.path.join(pixmap_path, "%s-%d.png" % (name, size))
+
+ if w and h:
+ return gtk.gdk.pixbuf_new_from_file_at_size(fname, w, h)
+ else:
+ return gtk.gdk.pixbuf_new_from_file(fname)
Index: umitGUI/MainWindow.py
===================================================================
--- umitGUI/MainWindow.py (revision 3791)
+++ umitGUI/MainWindow.py (working copy)
@@ -56,6 +56,9 @@
from umitCore.UmitConf import SearchConfig, is_maemo
from umitCore.UmitDB import Scans, UmitDB
+from umitPlugin.Window import PluginWindow
+from umitPlugin.Engine import PluginEngine
+
root = False
try:
if sys.platform == 'win32':
@@ -93,6 +96,7 @@
UmitMainWindow.__init__(self)
self.set_title(_("Umit"))
+ self._plugin_win = PluginWindow()
self._icontheme = gtk.IconTheme()
self.main_accel_group = gtk.AccelGroup()
@@ -114,6 +118,8 @@
self._profile_filechooser_dialog = None
self._results_filechooser_dialog = None
+ self._prepare_first_scan()
+
# Loading files passed as argument
files = option_parser.get_open_results()
if len(files) >= 1:
@@ -234,6 +240,13 @@
'<Control>r',
_('Use the selected scan profile to create another'),
self._new_scan_profile_with_selected_cb),
+
+ ('Extensions',
+ gtk.STOCK_INFO,
+ _('_Extensions'),
+ '<Control>e',
+ _('Extensions manager'),
+ self._show_plugin_manager),
('Quit',
gtk.STOCK_QUIT,
@@ -305,6 +318,8 @@
<menuitem action='Wizard'/>
<menuitem action='Compare Results'/>
<menuitem action='Search Scan'/>
+ <separator/>
+ <menuitem action='Extensions'/>
</menu>
<menu action='Profile'>
@@ -366,7 +381,10 @@
page = self._load(parsed_result=results[result][1],
title=results[result][1].scan_name)
page.status.set_search_loaded()
-
+
+ def _show_plugin_manager(self, widget, data=None):
+ self._plugin_win.show()
+
def _close_scan_cb(self, widget, data=None):
# data can be none, if the current page is to be closed
if data == None:
@@ -378,7 +396,7 @@
page = self.scan_notebook.get_nth_page(page_num)
filename = None
- if page == None:
+ if page == None or not isinstance(page, ScanNotebookPage):
return True
if page.status.unsaved_unchanged \
@@ -595,7 +613,23 @@
self.scan_notebook = ScanNotebook()
self.scan_notebook.close_scan_cb = self._close_scan_cb
self.scan_notebook.title_edited_cb = self._title_edited_cb
+
+ if is_maemo():
+ # No padding. We need space!
+ self.vbox.pack_start(self.scan_notebook, True, True, 0)
+ else:
+ self.vbox.pack_start(self.scan_notebook, True, True, 4)
+ # Conencting ScanNotebook Callbacks
+ self.scan_notebook.connect("page-removed", self._update_when_removed)
+ self.scan_notebook.connect("page-added", self._update_when_added)
+
+ def _prepare_first_scan(self):
+ # Load here becouse some plugins require some signals
+ # Set the mainwindow and load the selected plugins
+ PluginEngine().core.mainwindow = self
+ PluginEngine().load_selected_plugins()
+
page = self._new_scan_cb()
self.scan_notebook.show_all()
@@ -627,17 +661,6 @@
page.toolbar.scan_button.set_sensitive(True)
page.start_scan_cb()
-
- if is_maemo():
- # No padding. We need space!
- self.vbox.pack_start(self.scan_notebook, True, True, 0)
- else:
- self.vbox.pack_start(self.scan_notebook, True, True, 4)
-
- # Conencting ScanNotebook Callbacks
- self.scan_notebook.connect("page-removed", self._update_when_removed)
- self.scan_notebook.connect("page-added", self._update_when_added)
-
def _update_when_removed(self, notebook, child, pagenum):
self._update_main_menu()
@@ -1003,6 +1026,9 @@
# Cleaning up data base
UmitDB().cleanup(SearchConfig().converted_save_time)
+ # Saving the plugins
+ PluginEngine().plugins.save_changes()
+
gtk.main_quit()
def _load_diff_compare_cb (self, widget=None, extra=None):
Index: umitGUI/ScanNotebook.py
===================================================================
--- umitGUI/ScanNotebook.py (revision 3791)
+++ umitGUI/ScanNotebook.py (working copy)
@@ -45,6 +45,8 @@
from umitCore.UmitLogging import log
from umitCore.I18N import _
+from umitPlugin.Engine import PluginEngine
+
from types import StringTypes
icon_dir = Path.pixmaps_dir
@@ -284,6 +286,10 @@
class ScanNotebookPage(HIGVBox):
+ __gsignals__ = {
+ 'scan-finished' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ())
+ }
+
def __init__(self):
HIGVBox.__init__(self)
@@ -319,6 +325,8 @@
self._pack_noexpand_nofill(self.top_box)
self._pack_expand_fill(self.scan_result)
+ PluginEngine().core.emit('ScanNotebookPage-created', self)
+
def target_focus(self):
self.toolbar.target_entry.child.grab_focus()
@@ -644,6 +652,7 @@
return True
else:
self.parse_result(self.command_execution.get_xml_output_file())
+ self.emit("scan-finished")
return False
def load_result(self, file_to_parse):
@@ -1272,6 +1281,8 @@
self.append_page(self.host_details_page, gtk.Label(_('Host Details')))
self.append_page(self.scan_details_page, gtk.Label(_('Scan Details')))
+ PluginEngine().core.emit('ScanResultNotebook-created', self)
+
def get_nmap_output(self):
return self.nmap_output.get_map_output()
Index: umitCore/BasePaths.py
===================================================================
--- umitCore/BasePaths.py (revision 3791)
+++ umitCore/BasePaths.py (working copy)
@@ -43,6 +43,7 @@
MISC_DIR = os.path.join(main_dir, "share", "umit", "misc")
ICONS_DIR = os.path.join(main_dir, "share", "icons", "umit")
PIXMAPS_DIR = os.path.join(main_dir, "share", "pixmaps", "umit")
+PLUGINS_DIR = os.path.join(main_dir, "share", "umit", "plugins")
DOCS_DIR = os.path.join(main_dir, "share", "doc", "umit")
base_paths = dict(config_file = 'umit.conf',
@@ -57,6 +58,7 @@
umit_opf = 'umit.opf',
umit_opt = 'umit.opt',
pixmaps_dir = PIXMAPS_DIR,
+ plugins_dir = PLUGINS_DIR,
i18n_dir = LOCALE_DIR,
i18n_message_file = 'umit.mo',
scan_results_extension = 'usr', # comes from umit scan
result
Index: umitCore/Paths.py
===================================================================
--- umitCore/Paths.py (revision 3791)
+++ umitCore/Paths.py (working copy)
@@ -245,6 +245,9 @@
and access(user_home, R_OK and W_OK)\
and not exists(user_dir):
mkdir(user_dir)
+ mkdir(join(user_dir, "plugins"))
+ mkdir(join(user_dir, "plugins-download"))
+ mkdir(join(user_dir, "plugins-temp"))
log.debug(">>> Umit user dir successfully created! %s" % user_dir)
else:
log.warning(">>> No permissions to create user dir!")
Index: umitCore/UmitConf.py
===================================================================
--- umitCore/UmitConf.py (revision 3791)
+++ umitCore/UmitConf.py (working copy)
@@ -21,6 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import re
+import os
from types import StringTypes
from ConfigParser import NoSectionError, NoOptionError
@@ -537,6 +538,55 @@
modified = property(get_modified, set_modified)
not_present = property(get_not_present, set_not_present)
+class Plugins(object):
+ def __init__(self):
+ self.parser = Path.config_parser
+ self.section_name = "plugins"
+ self.separator = os.pathsep
+
+ if not self.parser.has_section(self.section_name):
+ self.create_section()
+
+ def save_changes(self):
+ self.parser.save_changes()
+
+ def create_section(self):
+ from os.path import join
+ self.paths = [join(Path.config_dir, "plugins")]
+ self.plugins = ""
+
+ def __get_it(self, p_name):
+ value = None
+
+ try: value = self.parser.get(self.section_name, p_name)
+ except: pass
+ finally: return self.sanity_settings(value)
+
+ def __set_it(self, property_name, settings):
+ settings = self.sanity_settings(settings)
+ self.parser.set(self.section_name, property_name, settings)
+
+ def sanity_settings(self, settings):
+ # FIXME: more sensed :D
+ if not settings:
+ return ""
+ return settings
+
+ def get_paths(self):
+ return filter(None, self.__get_it("paths").split(self.separator))
+
+ def set_paths(self, settings):
+ self.__set_it("paths", self.separator.join(settings))
+
+ def get_plugins(self):
+ return filter(None, self.__get_it("plugins").split(self.separator))
+
+ def set_plugins(self, settings):
+ self.__set_it("plugins", self.separator.join(settings))
+
+ paths = property(get_paths, set_paths)
+ plugins = property(get_plugins, set_plugins)
+
# Exceptions
class ProfileNotFound:
def __init__ (self, profile):
@@ -552,4 +602,4 @@
if __name__ == "__main__":
- pass
\ No newline at end of file
+ pass
Property changes on: umitPlugin
___________________________________________________________________
Added: svn:ignore
+ *.pyc
*.ump
*~
Index: higwidgets/higbuttons.py
===================================================================
--- higwidgets/higbuttons.py (revision 3791)
+++ higwidgets/higbuttons.py (working copy)
@@ -27,9 +27,10 @@
button related classes
"""
-__all__ = ['HIGMixButton', 'HIGButton']
+__all__ = ['HIGMixButton', 'HIGButton', 'HIGArrowButton', 'MiniButton']
import gtk
+import gobject
class HIGMixButton (gtk.HBox):
def __init__(self, title, stock):
@@ -73,3 +74,80 @@
self.set_use_stock(True)
else:
gtk.ToggleButton.__init__(self)
+
+class MiniButton(gtk.Button):
+ def __init__(self, stock, size=gtk.ICON_SIZE_MENU):
+ super(MiniButton, self).__init__()
+
+ self.img = gtk.image_new_from_stock(stock, size)
+
+ hbox = gtk.HBox(False, 2)
+ hbox.pack_start(self.img)
+ hbox.show_all()
+
+ self.add(hbox)
+ self.set_size_request(*self.img.size_request())
+
+class HIGArrowButton(gtk.Button):
+ __gsignals__ = {
+ 'force-clicked' : (gobject.SIGNAL_RUN_LAST, None, ())
+ }
+
+ def __init__(self, orient):
+ super(HIGArrowButton, self).__init__()
+
+ # Fascist mode!
+ self.arrow = gtk.Arrow(gtk.ARROW_RIGHT, gtk.SHADOW_ETCHED_IN)
+
+ # No genocide yet :)
+ self._active = False
+ self.orientation = orient
+
+ self.add(self.arrow)
+
+ def set_orientation(self, orient):
+ shadow = self.arrow.get_property("shadow-type")
+
+ if orient == gtk.ORIENTATION_HORIZONTAL:
+ self.orient = gtk.ORIENTATION_HORIZONTAL
+
+ if self.get_active():
+ self.arrow.set(gtk.ARROW_LEFT, shadow)
+ else:
+ self.arrow.set(gtk.ARROW_RIGHT, shadow)
+ else:
+ self.orient = gtk.ORIENTATION_VERTICAL
+
+ if self.get_active():
+ self.arrow.set(gtk.ARROW_UP, shadow)
+ else:
+ self.arrow.set(gtk.ARROW_DOWN, shadow)
+
+ def do_button_press_event(self, event):
+ if event.button == 3:
+ self.emit('force-clicked')
+
+ return gtk.Button.do_button_press_event(self, event)
+
+ def get_orientation(self):
+ return self.orient
+
+ def set_shadow(self, value):
+ direction = self.arrow.get_property("arrow-type")
+ self.arrow.set(direction, value)
+
+ def get_shadow(self, value):
+ return self.arrow.get_property("shadow-type")
+
+ def get_active(self):
+ return self._active
+
+ def set_active(self, val):
+ self._active = val
+ self.orientation = self.orientation
+
+ orientation = property(get_orientation, set_orientation)
+ shadow_type = property(get_shadow, set_shadow)
+ active = property(get_active, set_active)
+
+gobject.type_register(HIGArrowButton)
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Umit-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/umit-devel