def __init__(self, netzob):
     self.netzob = netzob
     self.log = logging.getLogger(
         'netzob.UI.Export.Controllers.RawExportController.py')
     self.model = RawExport(netzob)
     self.view = RawExportView()
     self.initCallbacks()
     self.update()
Exemple #2
0
 def __init__(self, netzob):
     self.netzob = netzob
     self.log = logging.getLogger('netzob.UI.Export.Controllers.RawExportController.py')
     self.model = RawExport(netzob)
     self.view = RawExportView()
     self.initCallbacks()
     self.update()
class RawExportController(object):

    #+----------------------------------------------
    #| Called when user select a new trace
    #+----------------------------------------------
    def new(self):
        pass

    def update(self):
        self.view.symbolTreeview.get_model().clear()
        for symbol in self.netzob.getCurrentProject().getVocabulary().getSymbols():
            iter = self.view.symbolTreeview.get_model().append(None, ["{0}".format(symbol.getID()), "{0} [{1}]".format(symbol.getName(), str(len(symbol.getMessages()))), '#000000', '#DEEEF0'])

    def clear(self):
        pass

    def kill(self):
        pass

    #+----------------------------------------------
    #| Constructor:
    #| @param netzob: the main netzob object
    #+----------------------------------------------
    def __init__(self, netzob):
        self.netzob = netzob
        self.log = logging.getLogger('netzob.UI.Export.Controllers.RawExportController.py')
        self.model = RawExport(netzob)
        self.view = RawExportView()
        self.initCallbacks()
        self.update()

    def initCallbacks(self):
        selection = self.view.symbolTreeview.get_selection()
        selection.connect("changed", self.symbolSelected_cb)

    def symbolSelected_cb(self, selection):
        (model, iter) = selection.get_selected()
        if(iter):
            if(model.iter_is_valid(iter)):
                symbolID = model.get_value(iter, 0)
                self.showXMLDefinition(symbolID)

    def showXMLDefinition(self, symbolID):
        if symbolID is None:
            self.log.debug("No selected symbol")
            self.view.textarea.get_buffer().set_text(_("Select a symbol to see its XML definition"))
        else:
            xmlDefinition = self.model.getXMLDefinition(symbolID)
            if xmlDefinition is not None:
                self.view.textarea.get_buffer().set_text("")
                self.view.textarea.get_buffer().insert_with_tags_by_name(self.view.textarea.get_buffer().get_start_iter(), xmlDefinition, "normalTag")
            else:
                self.view.textarea.get_buffer().set_text(_("No XML definition found"))

    #+----------------------------------------------
    #| GETTERS
    #+----------------------------------------------
    def getPanel(self):
        return self.view
class RawExportController(object):

    #+----------------------------------------------
    #| Called when user select a new trace
    #+----------------------------------------------
    def new(self):
        pass

    def update(self):
        self.view.symbolTreeview.get_model().clear()
        for symbol in self.netzob.getCurrentProject().getVocabulary(
        ).getSymbols():
            iter = self.view.symbolTreeview.get_model().append(
                None, [
                    "{0}".format(symbol.getID()), "{0} [{1}]".format(
                        symbol.getName(), str(len(symbol.getMessages()))),
                    '#000000', '#DEEEF0'
                ])

    def clear(self):
        pass

    def kill(self):
        pass

    #+----------------------------------------------
    #| Constructor:
    #| @param netzob: the main netzob object
    #+----------------------------------------------
    def __init__(self, netzob):
        self.netzob = netzob
        self.log = logging.getLogger(
            'netzob.UI.Export.Controllers.RawExportController.py')
        self.model = RawExport(netzob)
        self.view = RawExportView()
        self.initCallbacks()
        self.update()

    def initCallbacks(self):
        selection = self.view.symbolTreeview.get_selection()
        selection.connect("changed", self.symbolSelected_cb)

    def symbolSelected_cb(self, selection):
        (model, iter) = selection.get_selected()
        if (iter):
            if (model.iter_is_valid(iter)):
                symbolID = model.get_value(iter, 0)
                self.showXMLDefinition(symbolID)

    def showXMLDefinition(self, symbolID):
        if symbolID is None:
            self.log.debug("No selected symbol")
            self.view.textarea.get_buffer().set_text(
                _("Select a symbol to see its XML definition"))
        else:
            xmlDefinition = self.model.getXMLDefinition(symbolID)
            if xmlDefinition is not None:
                self.view.textarea.get_buffer().set_text("")
                self.view.textarea.get_buffer().insert_with_tags_by_name(
                    self.view.textarea.get_buffer().get_start_iter(),
                    xmlDefinition, "normalTag")
            else:
                self.view.textarea.get_buffer().set_text(
                    _("No XML definition found"))

    #+----------------------------------------------
    #| GETTERS
    #+----------------------------------------------
    def getPanel(self):
        return self.view