Ejemplo n.º 1
0
 def __init__(self, application, settings):
   self.application = application
   self.ui = GtkBuilderLoader(FILE_UI_MAIN)
   self.settings = settings
   self.loadUI()
   # Restore the intercepted syscalls list from settings
   saved_syscalls = settings.get_intercepted_syscalls()
   # Restore the options from settings
   self.ui.menuitemAutoClear.set_active(self.settings.get_boolean(
     SECTION_APPLICATION, 'autoclear',
     self.ui.menuitemAutoClear.get_active()))
   # Update the Show only called syscalls in counts status
   self.ui.menuitemCountsOnlyCalled.set_active(self.settings.get_boolean(
     SECTION_COUNTS, 'only called',
     self.ui.menuitemCountsOnlyCalled.get_active()))
   self.on_menuitemCountsOnlyCalled_toggled(None)
   # Update the Show only existing files status
   self.ui.menuitemFilesShowOnlyExisting.set_active(self.settings.get_boolean(
     SECTION_FILES, 'only existing',
     self.ui.menuitemFilesShowOnlyExisting.get_active()))
   self.on_menuitemFilesShowOnlyExisting_toggled(None)
   self.ui.infobarInformation.set_visible(False)
   # Load all the available syscall names
   for syscall in sorted(SYSCALL_NAMES.values()):
     prototype = SYSCALL_PROTOTYPES.get(syscall, ('', ( )))
     self.modelInterceptedSyscalls.add(items=(
       # If the configuration file has a list of intercepted syscalls then
       # set each syscall status accordingly
       saved_syscalls is None and True or syscall in saved_syscalls,
       # Add syscall name
       syscall,
       # Add return type
       prototype[0],
       # Add prototype arguments
       ', '.join(['%s %s' % m for m in prototype[1]]),
       # Does this syscall use any filename/pathname argument?
       any(argname in FILENAME_ARGUMENTS for argtype, argname in prototype[1]),
       # Is this syscall used by sockets?
       syscall in SOCKET_SYSCALL_NAMES,
     ))
     self.modelCounts.add(items=(syscall, 0, False))
   self.update_InterceptedSyscalls_count()
   # Restore the saved size and position
   if self.settings.get_value('width', 0) and self.settings.get_value('height', 0):
     self.ui.winMain.set_default_size(
       self.settings.get_value('width', -1),
       self.settings.get_value('height', -1))
   if self.settings.get_value('left', 0) and self.settings.get_value('top', 0):
     self.ui.winMain.move(
       self.settings.get_value('left', 0),
       self.settings.get_value('top', 0))
   # Restore visible columns
   for current_section in self.column_headers.get_sections():
     self.column_headers.load_visible_columns(current_section)
   # Set ModelFilter
   self.filtered_items = []
   self.ui.filterActivities.set_visible_func(self.check_for_filtered_syscall,
     self.filtered_items)
   # Set counts filter
   self.ui.filterCounts.set_visible_column(self.modelCounts.COL_VISIBILITY)
   self.ui.filterCounts.refilter()
   # Set counts filter
   self.ui.filterFiles.set_visible_column(self.modelFiles.COL_EXISTING)
   self.ui.filterFiles.refilter()
   # Load the others dialogs
   self.about = AboutWindow(self.ui.winMain, False)
   self.thread_loader = None
   self.debugger = None