Beispiel #1
0
    def __group_cell_func(self, col, cell, model, iter):
        obj = model.get_value(iter, 0)
        color, markup = self.style.mid[gtk.STATE_NORMAL], None

        if isinstance(obj, TFlag):
            color = None
            markup = '<b>%s</b>' % gobject.markup_escape_text(obj.ref)

        elif isinstance(obj, TField):
            # This is a property

            name = gobject.markup_escape_text(backend.get_field_name(obj.ref))
            proto = obj.proto

            if not backend.is_flags(obj.ref):
                color = None

            if backend.is_field_autofilled(obj.ref):
                markup = '<i>%s</i>' % name
            else:
                markup = '<b>%s</b>' % name
        else:
            # Ok. This is the protocol
            name = gobject.markup_escape_text(backend.get_proto_name(obj))
            markup = '<b>%s</b>' % name

        # Setting the values
        cell.set_property('cell-background-gdk', color)
        cell.set_property('markup', markup)
    def __cairo_draw(self, cr):
        cr.save()

        self.fields = {}
        self.protocols = []

        for protocol in self.packet.get_protocols():
            self.protocols.append(
                (protocol, self.__get_color(backend.get_proto_name(protocol))))

        self.draw_left(cr)
        self.draw_payload(cr)

        cr.restore()
Beispiel #3
0
    def __cairo_draw(self, cr):
        cr.save()

        self.fields = {}
        self.protocols = []

        for protocol in self.packet.get_protocols():
            self.protocols.append(
                    (protocol,
                     self.__get_color(backend.get_proto_name(protocol)))
            )

        self.draw_left(cr)
        self.draw_payload(cr)

        cr.restore()
Beispiel #4
0
    def __on_selection_changed(self, selection):
        model, iter = selection.get_selected()

        if not iter:
            return

        proto = model.get_value(iter, 0)

        if isinstance(proto, (TField, TFlag)):
            packet, proto, field = self.get_selected_field()

            self.emit('field-selected', packet, proto, field)
            self.emit('desc-changed', backend.get_field_desc(field))
        else:
            # We have selected the protocol
            self.emit('desc-changed', "%s protocol." % \
                      backend.get_proto_name(proto))
    def draw_left(self, cr):
        layout = self.create_pango_layout('')
        layout.set_font_description(pango.FontDescription(self.title_font))

        attr_layout = self.create_pango_layout('')
        attr_layout.set_font_description(pango.FontDescription(self.attr_font))

        cr.move_to(4, 4)

        for protocol, color in self.protocols:
            name = backend.get_proto_name(protocol)
            layout.set_text(name)

            w, h = self.draw_box(cr, layout, fill=color)

            cr.rel_move_to(0, h + 4)

            x, y = cr.get_current_point()
            cr.move_to(x + 10, y)

            for field in backend.get_proto_fields(protocol):

                if not backend.is_showable_field(field, self.packet):
                    continue

                name = backend.get_field_name(field)
                value = str(backend.get_field_value_repr(protocol, field))

                text = '%s: %s' % (name, value)

                if len(text) > 35:
                    text = text[0:32] + "..."

                attr_layout.set_text(text)

                f_w, f_h = self.draw_text(cr, attr_layout)

                # Start point
                x, y = cr.get_current_point()
                self.fields[(protocol, name)] = [(x + f_w + 4, y + (f_h / 2.0))
                                                 ]

                cr.rel_move_to(0, f_h)

            cr.rel_move_to(-10, 10)
Beispiel #6
0
    def draw_left(self, cr):
        layout = self.create_pango_layout('')
        layout.set_font_description(pango.FontDescription(self.title_font))

        attr_layout = self.create_pango_layout('')
        attr_layout.set_font_description(pango.FontDescription(self.attr_font))

        cr.move_to(4, 4)

        for protocol, color in self.protocols:
            name = backend.get_proto_name(protocol)
            layout.set_text(name)

            w, h = self.draw_box(cr, layout, fill=color)

            cr.rel_move_to(0, h + 4)

            x, y = cr.get_current_point()
            cr.move_to(x + 10, y)

            for field in backend.get_proto_fields(protocol):

                if not backend.is_showable_field(field, self.packet):
                    continue

                name = backend.get_field_name(field)
                value = str(backend.get_field_value_repr(protocol, field))

                text = '%s: %s' % (name, value)

                if len(text) > 35:
                    text = text[0:32] + "..."

                attr_layout.set_text(text)

                f_w, f_h = self.draw_text(cr, attr_layout)

                # Start point
                x, y = cr.get_current_point()
                self.fields[(protocol, name)] = [(x + f_w + 4, y + (f_h / 2.0))]

                cr.rel_move_to(0, f_h)

            cr.rel_move_to(-10, 10)
    def reload(self):
        self.store.clear()

        if not self.session.packet:
            return

        log.debug('Reloading ProtocolHierarchy with %s' % \
                  self.session.packet.summary())

        root = None

        # We pray to be ordered :(
        for proto in backend.get_packet_protos(self.session.packet):
            root = self.store.append(root, [self.proto_icon,
                                            backend.get_proto_name(proto),
                                            proto])

        self.tree.expand_all()
        self.tree.get_selection().select_path((0, ))
Beispiel #8
0
    def populate(self, packets):
        self.store.clear()

        dct = defaultdict(int)

        for packet in packets:
            names = [backend.get_proto_name(proto) \
                     for proto in packet.get_protocols()]

            for name in names:
                dct[name] += 1

        sortable = [(v, k) for (k, v) in dct.items()]
        sortable.sort()
        sortable.reverse()

        self.store.append([self.icon, _('No filter')])

        for value, name in sortable:
            self.store.append([self.icon, name])

        self.set_active(0)
    def populate(self, packets):
        self.store.clear()

        dct = defaultdict(int)

        for packet in packets:
            names = [backend.get_proto_name(proto) \
                     for proto in packet.get_protocols()]

            for name in names:
                dct[name] += 1

        sortable = [(v, k) for (k, v) in dct.items()]
        sortable.sort()
        sortable.reverse()

        self.store.append([self.icon, _('No filter')])

        for value, name in sortable:
            self.store.append([self.icon, name])

        self.set_active(0)