From c3f49c52efdd6b348bc603a97e891e984b8560cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Sun, 20 Oct 2013 20:45:38 +0200 Subject: [PATCH] Show number of recv() calls --- examples/cpushark/Capture.py | 6 ++-- examples/cpushark/MainWindow.xib | 43 ++++++++++++++++++----- examples/cpushark/MainWindowController.py | 4 +++ 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/examples/cpushark/Capture.py b/examples/cpushark/Capture.py index 3bfa78b..48ed59b 100644 --- a/examples/cpushark/Capture.py +++ b/examples/cpushark/Capture.py @@ -18,6 +18,7 @@ class Capture(NSObject): self.session = None self.script = None self.modules = Modules() + self.recvTotal = 0 self.calls = Calls(self) return self @@ -104,7 +105,7 @@ class Capture(NSObject): self._updateState_(CaptureState.ATTACHED) else: self._updateState_(CaptureState.DETACHED) - self.delegate.captureFailedToAttachWithError_(error) + self._delegate.captureFailedToAttachWithError_(error) def _sessionDidDetach(self): if self.state == CaptureState.ATTACHING or self.state == CaptureState.ATTACHED: @@ -121,7 +122,8 @@ class Capture(NSObject): elif fromAddress == "/stalker/calls" and name == '+add': self.calls._add_(stanza['payload']) elif fromAddress == "/interceptor/functions" and name == '+add': - pass + self.recvTotal += 1 + self._delegate.captureRecvTotalDidChange() else: if not self.calls._handleStanza_(stanza): print "Woot! Got stanza: %s from=%s" % (stanza['name'], stanza['from']) diff --git a/examples/cpushark/MainWindow.xib b/examples/cpushark/MainWindow.xib index 5f4fab7..6cd6feb 100644 --- a/examples/cpushark/MainWindow.xib +++ b/examples/cpushark/MainWindow.xib @@ -12,6 +12,8 @@ + + @@ -21,10 +23,10 @@ - - + + - + @@ -129,14 +131,14 @@ DQ - + - + - + @@ -169,7 +171,7 @@ DQ - + @@ -192,22 +194,45 @@ DQ - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/cpushark/MainWindowController.py b/examples/cpushark/MainWindowController.py index 6627212..63e14df 100644 --- a/examples/cpushark/MainWindowController.py +++ b/examples/cpushark/MainWindowController.py @@ -9,6 +9,7 @@ class MainWindowController(NSWindowController): attachProgress = objc.IBOutlet() attachButton = objc.IBOutlet() detachButton = objc.IBOutlet() + recvTotalLabel = objc.IBOutlet() callTableView = objc.IBOutlet() def __new__(cls): @@ -118,6 +119,9 @@ class MainWindowController(NSWindowController): def captureFailedToAttachWithError_(self, error): NSRunCriticalAlertPanel("Error", "Failed to attach: %s" % error, None, None, None) + def captureRecvTotalDidChange(self): + self.recvTotalLabel.setStringValue_(self.capture.recvTotal) + def callsDidChange(self): self.callTableView.reloadData()