def setDescription(self): # Present a nice description of the rule: if self.previous_frame == 1: # SNAT snat_source_icon = self.getNetwork(unicode(self.snat_source_combo.currentText())).getIcon() snat_destination_icon = self.getNetwork(unicode(self.snat_translate_combo.currentText())).getIcon() desc = htmlTitle(tr('Source address translation')) table = [ ('', htmlImage(snat_source_icon) + ' ' + self.snat_source_combo.currentText()), (tr('when connecting to '), htmlImage(snat_destination_icon) + ' ' + self.snat_translate_combo.currentText()), (tr('translates into '), htmlImage(Resource.ICONS[INTERFACE_RESTYPE]) + ' ' + 'Firewall.') ] else: # DNAT dnat_source_icon = self.getNetwork(unicode(self.dnat_source_combo.currentText())).getIcon() dnat_destination_icon = self.getNetwork(unicode(self.dnat_translate_combo.currentText())).getIcon() desc = htmlTitle(tr('Destination address translation')) table = [ ('', htmlImage(dnat_source_icon) + ' ' + self.dnat_source_combo.currentText()), (tr('when connecting to '), htmlImage(Resource.ICONS[INTERFACE_RESTYPE]) + ' ' + 'Firewall.') ] protocols = self.window.getLibrary('protocols') if self.dnat_port_combo.currentIndex() != 0: identifier = unicode(self.dnat_port_combo.currentText()) dnat_port_icon = protocols[identifier].getIcon() table += [ (tr('on port '), htmlImage(dnat_port_icon) + ' ' + self.dnat_port_combo.currentText()) ] table += [ (tr('connects to'), htmlImage(dnat_destination_icon) + ' ' + self.dnat_translate_combo.currentText()) ] if self.dnat_port_combo.currentIndex() != 0 and self.dnat_port_nated_checkbox.checkState() == Qt.Checked: identifier = unicode(self.dnat_port_nated_combo.currentText()) dnat_port_icon = protocols[identifier].getIcon() table += [ (tr('on port '), htmlImage(dnat_port_icon) + ' ' + self.dnat_port_nated_combo.currentText()) ] desc += htmlTable(table) self.rule_description.setText(unicode(desc))
def information(self, object, highlight=True): if highlight: self.highlight(object['id']) icon = object.getIcon() title, options = object.createInformation() title = tr('%s:') % title if self.window.debug: object.createDebugOptions(options) html = htmlTitle(title, icon) + htmlTable(options) self.window.setInfo(html, background=object.getBackground())
def information(self, rule_id, highlight=True): try: rule = self[rule_id] except KeyError: return title, options = rule.createInformation() title = tr('%s:') % title if self.window.debug: rule.createDebugOptions(options) if rule['editable']: url = self.edit_format % rule['id'] title = htmlLink(url, title) html = htmlTitle(title) + htmlTable(options) self.window.setInfo(html, background=rule.getBackground()) if highlight: self.highlight(rule_id, information=False)