Ejemplo n.º 1
0
    def __on_activate_plugin(self, cell, path):
        model = self.tree.get_model()
        iter = model.get_iter(path)

        plugin = model.get_value(iter, COLUMN_OBJECT)

        if not plugin:
            return

        if not plugin.enabled:
            func = self.p_window.engine.load_plugin
        else:
            func = self.p_window.engine.unload_plugin

        ret, errmsg = func(plugin)

        if not ret:
            dialog = HIGAlertDialog(PMApp().main_window,
                                    gtk.DIALOG_MODAL,
                                    gtk.MESSAGE_ERROR,
                                    message_format=errmsg,
                                    secondary_text=errmsg.summary)
            dialog.run()
            dialog.hide()
            dialog.destroy()
Ejemplo n.º 2
0
    def __on_open_session(self, action):
        types = {}
        sessions = (backend.StaticContext, backend.SequenceContext,
                    backend.SniffContext)

        for ctx in sessions:
            for name, pattern in ctx.file_types:
                types[pattern] = (name, ctx)

        dialog = gtk.FileChooserDialog(
            _("Select a session"),
            self,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
                     gtk.RESPONSE_ACCEPT))
        dialog.set_transient_for(self)

        filterall = gtk.FileFilter()
        filterall.set_name(_('All supported files'))
        [filterall.add_pattern(k) for k in types]
        dialog.add_filter(filterall)

        for pattern, (name, ctx) in types.items():
            filter = gtk.FileFilter()
            filter.set_name(name)
            filter.add_pattern(pattern)
            dialog.add_filter(filter)

        if dialog.run() == gtk.RESPONSE_ACCEPT:
            ctx = None
            fname = dialog.get_filename()

            try:
                find = fname.split('.')[-1]

                for pattern in types:
                    if pattern.split('.')[-1] == find:
                        ctx = types[pattern][1]
            except:
                pass

            if ctx is not backend.SequenceContext and \
               ctx is not backend.SniffContext and \
               ctx is not backend.StaticContext:

                d = HIGAlertDialog(
                    type=gtk.MESSAGE_ERROR,
                    message_format=_("Unable to open selected session"),
                    secondary_text=_(
                        "PacketManipulator is unable to guess the "
                        "file type. Try to modify the extension "
                        "and to reopen the file."))
                d.set_transient_for(self)
                d.run()
                d.destroy()
            else:
                self.open_generic_file_async(fname)

        dialog.hide()
        dialog.destroy()
Ejemplo n.º 3
0
    def __on_open_session(self, action):
        types = {}
        sessions = (backend.StaticContext,
                    backend.SequenceContext,
                    backend.SniffContext)

        for ctx in sessions:
            for name, pattern in ctx.file_types:
                types[pattern] = (name, ctx)

        dialog = gtk.FileChooserDialog(_("Select a session"), self,
                               buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                        gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT))
        dialog.set_transient_for(self)

        filterall = gtk.FileFilter()
        filterall.set_name(_('All supported files'))
        [filterall.add_pattern(k) for k in types]
        dialog.add_filter(filterall)

        for pattern, (name, ctx) in types.items():
            filter = gtk.FileFilter()
            filter.set_name(name)
            filter.add_pattern(pattern)
            dialog.add_filter(filter)

        if dialog.run() == gtk.RESPONSE_ACCEPT:
            ctx = None
            fname = dialog.get_filename()

            try:
                find = fname.split('.')[-1]

                for pattern in types:
                    if pattern.split('.')[-1] == find:
                        ctx = types[pattern][1]
            except:
                pass

            if ctx is not backend.SequenceContext and \
               ctx is not backend.SniffContext and \
               ctx is not backend.StaticContext:

                d = HIGAlertDialog(type=gtk.MESSAGE_ERROR,
                    message_format=_("Unable to open selected session"),
                    secondary_text=_("PacketManipulator is unable to guess the "
                                     "file type. Try to modify the extension "
                                     "and to reopen the file."))
                d.set_transient_for(self)
                d.run()
                d.destroy()
            else:
                self.open_generic_file_async(fname)

        dialog.hide()
        dialog.destroy()
Ejemplo n.º 4
0
    def _send_report(self):
        if self.description == "" or self.email == "":
            cancel_dialog = HIGAlertDialog(type=gtk.MESSAGE_ERROR,
                message_format=_("Bug report is incomplete!"),
                secondary_text=_("The bug report is incomplete. "
                    "You must inform a description that explains clearly "
                    "what is happening and a valid e-mail, so you can be "
                    "contacted when the bug gets fixed."))
            cancel_dialog.run()
            cancel_dialog.destroy()
            return self.restore_state()

        bug_register = BugRegister(self.emsg)
        bug_register.reporter = self.email

        idx = self.description.find('\n{{{\n')

        if idx > 0:
            bug_register.details = \
                self.description[:idx + 1].replace("\n", "[[BR]]") + \
                self.description[idx:]
        else:
            bug_register.details = self.description.replace("\n", "[[BR]]")

        bug_page = None
        try:
            bug_page = bug_register.report()
            assert bug_page
        except Exception, err:
            cancel_dialog = HIGAlertDialog(type=gtk.MESSAGE_ERROR,
                message_format=_("Bug not reported!"),
                secondary_text=_("The bug description could not be "
                    "reported. This problem may be caused by the lack "
                    "of Internet access or indisponibility of the bug "
                    "tracker server. Please, verify your internet access, "
                    "and then try to report the bug once again."))
            cancel_dialog.run()
            cancel_dialog.destroy()
            return self.restore_state()
Ejemplo n.º 5
0
    def __on_row_action(self, widget, row):
        "Enable/Disable menu/button callback"

        if not row.enabled:
            func = self.p_window.engine.load_plugin
        else:
            func = self.p_window.engine.unload_plugin

        ret, errmsg = func(row.reader)

        if not ret:
            dialog = HIGAlertDialog(
                self.p_window,
                gtk.DIALOG_MODAL,
                gtk.MESSAGE_ERROR,
                message_format=errmsg,
                secondary_text=errmsg.summary
            )
            dialog.run()
            dialog.destroy()
        else:
            row.enabled = not row.enabled
Ejemplo n.º 6
0
    def __on_response(self, dialog, response_id):
        if response_id == gtk.RESPONSE_ACCEPT:
            opts = self.get_options()

            if opts['capmethod'] == 1 and not opts['capfile']:
                log.debug(
                    'Capture method selected is virtual interface but '
                    'the file entry is empty. Stopping response emission')

                self.stop_emission('response')

                d = HIGAlertDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT | \
                                         gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
                                   message_format=_("Some options are missing"),
                                   secondary_text=_("You've selected Virtual "
                                                    "interface as capture "
                                                    "method. You need to "
                                                    "specify a file source to "
                                                    "read from"))
                d.run()
                d.hide()
                d.destroy()
Ejemplo n.º 7
0
    def __on_response(self, dialog, response_id):
        if response_id == gtk.RESPONSE_ACCEPT:
            opts = self.get_options()

            if opts['capmethod'] == 1 and not opts['capfile']:
                log.debug('Capture method selected is virtual interface but '
                          'the file entry is empty. Stopping response emission')

                self.stop_emission('response')

                d = HIGAlertDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT | \
                                         gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
                                   message_format=_("Some options are missing"),
                                   secondary_text=_("You've selected Virtual "
                                                    "interface as capture "
                                                    "method. You need to "
                                                    "specify a file source to "
                                                    "read from"))
                d.run()
                d.hide()
                d.destroy()
Ejemplo n.º 8
0
    def __on_row_action(self, widget, row):
        "Enable/Disable menu/button callback"

        if not row.enabled:
            func = self.p_window.engine.load_plugin
        else:
            func = self.p_window.engine.unload_plugin

        ret, errmsg = func(row.reader)

        if not ret:
            dialog = HIGAlertDialog(self.p_window,
                                    gtk.DIALOG_MODAL,
                                    gtk.MESSAGE_ERROR,
                                    message_format=errmsg,
                                    secondary_text=errmsg.summary)
            dialog.run()
            dialog.destroy()
        else:
            row.enabled = not row.enabled
Ejemplo n.º 9
0
            assert bug_page
        except Exception, err:
            cancel_dialog = HIGAlertDialog(type=gtk.MESSAGE_ERROR,
                message_format=_("Bug not reported!"),
                secondary_text=_("The bug description could not be "
                    "reported. This problem may be caused by the lack "
                    "of Internet access or indisponibility of the bug "
                    "tracker server. Please, verify your internet access, "
                    "and then try to report the bug once again."))
            cancel_dialog.run()
            cancel_dialog.destroy()
            return self.restore_state()
        else:
            ok_dialog = HIGAlertDialog(type=gtk.MESSAGE_INFO,
                message_format=_("Bug sucessfully reported!"),
                secondary_text=_("The bug description was sucessfully "
                    "reported. A web page with detailed description about "
                    "this report will be opened in your default web browser "
                    "now."))
            ok_dialog.run()
            ok_dialog.destroy()

        if bug_page:
            try:
                webbrowser.open(bug_page, autoraise=1)
            except: # XXX What exceptions should be caught here ?
                page_dialog = HIGAlertDialog(type=gtk.MESSAGE_ERROR,
                    message_format=_("Could not open default Web Browser"),
                    secondary_text=_("PM was unable to open your default "
                        "web browser to show the bug tracker page with the "
                        "report status. Try visiting Umit's bug tracker "
                        "page to see if your bug was reported."))
Ejemplo n.º 10
0
 def dialog(txt, sec):
     return HIGAlertDialog(self.p_window, 0, gtk.MESSAGE_QUESTION, \
         gtk.BUTTONS_YES_NO, txt, sec)
Ejemplo n.º 11
0
        #    ctx.join()

        errs = []

        try:
            log.debug('Saving options before exiting')
            Prefs().write_options()
        except IOError, err:
            errs.append(err)

        try:
            log.debug('Saving audit configurations')
            AuditManager().write_configurations()
        except IOError, err:
            errs.append(err)

        if errs:
            errstr = '\n'.join(
                map(lambda x: 'on %s (%s)' % (x.filename, x.strerror), errs))

            dialog = HIGAlertDialog(
                type=gtk.MESSAGE_ERROR,
                message_format=_('Error while saving configurations'),
                secondary_text=errstr + '\n\n' + _('Be sure to have ' \
                                 'read and write permission.'))
            dialog.set_transient_for(self)
            dialog.run()
            dialog.destroy()

        gtk.main_quit()
Ejemplo n.º 12
0
    def _send_report(self):
        if self.description == "" or self.email == "":
            cancel_dialog = HIGAlertDialog(
                type=gtk.MESSAGE_ERROR,
                message_format=_("Bug report is incomplete!"),
                secondary_text=_(
                    "The bug report is incomplete. "
                    "You must inform a description that explains clearly "
                    "what is happening and a valid e-mail, so you can be "
                    "contacted when the bug gets fixed."))
            cancel_dialog.run()
            cancel_dialog.destroy()
            return self.restore_state()

        bug_register = BugRegister(self.emsg)
        bug_register.reporter = self.email

        idx = self.description.find('\n{{{\n')

        if idx > 0:
            bug_register.details = \
                self.description[:idx + 1].replace("\n", "[[BR]]") + \
                self.description[idx:]
        else:
            bug_register.details = self.description.replace("\n", "[[BR]]")

        bug_page = None
        try:
            bug_page = bug_register.report()
            assert bug_page
        except Exception, err:
            cancel_dialog = HIGAlertDialog(
                type=gtk.MESSAGE_ERROR,
                message_format=_("Bug not reported!"),
                secondary_text=_(
                    "The bug description could not be "
                    "reported. This problem may be caused by the lack "
                    "of Internet access or indisponibility of the bug "
                    "tracker server. Please, verify your internet access, "
                    "and then try to report the bug once again."))
            cancel_dialog.run()
            cancel_dialog.destroy()
            return self.restore_state()
Ejemplo n.º 13
0
                type=gtk.MESSAGE_ERROR,
                message_format=_("Bug not reported!"),
                secondary_text=_(
                    "The bug description could not be "
                    "reported. This problem may be caused by the lack "
                    "of Internet access or indisponibility of the bug "
                    "tracker server. Please, verify your internet access, "
                    "and then try to report the bug once again."))
            cancel_dialog.run()
            cancel_dialog.destroy()
            return self.restore_state()
        else:
            ok_dialog = HIGAlertDialog(
                type=gtk.MESSAGE_INFO,
                message_format=_("Bug sucessfully reported!"),
                secondary_text=_(
                    "The bug description was sucessfully "
                    "reported. A web page with detailed description about "
                    "this report will be opened in your default web browser "
                    "now."))
            ok_dialog.run()
            ok_dialog.destroy()

        if bug_page:
            try:
                webbrowser.open(bug_page, autoraise=1)
            except:  # XXX What exceptions should be caught here ?
                page_dialog = HIGAlertDialog(
                    type=gtk.MESSAGE_ERROR,
                    message_format=_("Could not open default Web Browser"),
                    secondary_text=_(
                        "PM was unable to open your default "
    def on_save_log(self, action, selection=False):
        if selection:
            model, rows = self.get_selection().get_selected_rows()

            if not rows:
                return

        dialog = gtk.FileChooserDialog(_('Save log file'), PMApp().main_window,
                                       gtk.FILE_CHOOSER_ACTION_SAVE,
                                       (gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT,
                                        gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))

        afilter = gtk.FileFilter()
        afilter.add_pattern('*.txt')
        afilter.add_pattern('*.log')
        afilter.add_mime_type('text/plain')
        afilter.set_name('ASCII log file')

        dialog.add_filter(afilter)

        xfilter = gtk.FileFilter()
        xfilter.add_pattern('*.xml')
        xfilter.add_mime_type('text/html')
        xfilter.set_name('XML log file')

        dialog.add_filter(xfilter)

        if dialog.run() == gtk.RESPONSE_ACCEPT:
            outname = dialog.get_filename()
            type = (dialog.get_filter() is xfilter and 1 or 0)

            if exists(outname):
                d = gtk.MessageDialog(PMApp().main_window,
                                      gtk.DIALOG_MODAL,
                                      gtk.BUTTONS_YES_NO,
                                      _('A file named %s already exists. Do '
                                        'want overwrite it?') % outname)
                ret = d.run()
                d.hide()
                d.destroy()

                if ret == gtk.RESPONSE_NO:
                    dialog.hide()
                    dialog.destroy()

                    return

            try:
                f = open(outname, 'w')

                if type == 1:
                    f.write('<?xml version="1.0"?>\n<auditlog>\n')
                    sep = ' '
                else:
                    sep = ''

                if selection:
                    for path in rows:
                        iter = model.get_iter(path)
                        f.write(sep + \
                                self.get_row_txt(model, iter, type) + \
                                '\n')
                else:
                    def dump(model, path, iter, f):
                        f.write(sep + \
                                self.get_row_txt(model, iter, type) + \
                                '\n')

                    self.store.foreach(dump, f)

                if type == 1:
                    f.write('</auditlog>\n')

                f.close()

            except Exception, err:
                try:
                    unlink(outname)
                except:
                    pass

                d = HIGAlertDialog(PMApp().main_window, gtk.DIALOG_MODAL,
                                   gtk.MESSAGE_ERROR,
                                   message_format=_('Error while saving log '
                                                    'file to %s') % outname,
                                   secondary_text=str(err))
                d.run()
                d.hide()
                d.destroy()
Ejemplo n.º 15
0
        errs = []

        try:
            log.debug('Saving options before exiting')
            Prefs().write_options()
        except IOError, err:
            errs.append(err)

        try:
            log.debug('Saving audit configurations')
            AuditManager().write_configurations()
        except IOError, err:
            errs.append(err)

        if errs:
            errstr = '\n'.join(
                map(lambda x: 'on %s (%s)' % (x.filename, x.strerror),
                errs)
            )

            dialog = HIGAlertDialog(
                type=gtk.MESSAGE_ERROR,
                message_format=_('Error while saving configurations'),
                secondary_text=errstr + '\n\n' + _('Be sure to have ' \
                                 'read and write permission.'))
            dialog.set_transient_for(self)
            dialog.run()
            dialog.destroy()

        gtk.main_quit()