# HG changeset patch
# User Markus Bröker
# Date 1229179518 -3600
# Node ID 826dd5531eb046f4749f322ab47e61bb83a4af5a
svn copy of qmonitor
diff --git a/PacketParser.cpp b/PacketParser.cpp
new file mode 100644
--- /dev/null
+++ b/PacketParser.cpp
@@ -0,0 +1,179 @@
+/*
+ * $Id: PacketParser.cpp 54 2008-01-10 00:24:52Z mbroeker $
+ * $URL: http://localhost/svn/cpp/qMonitor/trunk/PacketParser.cpp $
+ */
+
+#include
+#include
+
+PacketParser::PacketParser (int tm)
+:PacketReader (tm)
+{
+ protocol = IPPROTO_IP;
+ port = 0;
+}
+
+PacketParser::PacketParser (std::string filename)
+: PacketReader (filename)
+{
+ protocol = IPPROTO_IP;
+ port = 0;
+}
+
+PacketParser::~PacketParser ()
+{
+}
+
+std::string PacketParser::getProtocol (int i)
+{
+ proto = getprotobynumber (i);
+ return ((proto != NULL) ? proto->p_name : "unknown");
+}
+
+std::string PacketParser::getPacket ()
+{
+ if (port != 0)
+ if ((sport != port) && (dport != port))
+ return "";
+
+ return str;
+}
+
+void PacketParser::setPort (unsigned short p)
+{
+ port = p;
+}
+
+void PacketParser::setProtocol (int proto)
+{
+ protocol = proto;
+}
+
+std::string PacketParser::read ()
+{
+ std::ostringstream s;
+ struct iphdr *iph;
+ struct tcphdr *tcph;
+ struct udphdr *udph;
+
+ struct in_addr src;
+ struct in_addr dst;
+
+ int size = 0;
+
+ uint i;
+
+ str = PacketReader::read ();
+
+ iph = (struct iphdr *)(str.c_str () + sizeof (struct ethhdr));
+
+ switch (iph->protocol) {
+ case IPPROTO_TCP:
+ size = sizeof (tcphdr);
+ break;
+ case IPPROTO_UDP:
+ size = sizeof (udphdr);
+ break;
+ case IPPROTO_ICMP:
+ size = sizeof (icmphdr);
+ break;
+ case IPPROTO_IP:
+ size += (sizeof (ethhdr) + sizeof (iphdr));
+ break;
+ default:
+ size += (sizeof (ethhdr) + sizeof (iphdr));
+ }
+
+ src.s_addr = (iph->saddr);
+ dst.s_addr = (iph->daddr);
+
+ dhost = inet_ntoa (dst);
+ shost = inet_ntoa (src);
+
+ s.str () = "";
+
+ if (protocol != iph->protocol) {
+ switch (protocol) {
+ case IPPROTO_IP:
+ /*
+ * filter the content later
+ */
+ break;
+
+ case IPPROTO_RAW:
+ for (i = size; i < str.length (); i++) {
+ if (!isgraph (str[i]))
+ s << ".";
+ else
+ s << str[i];
+ }
+ return s.str ();
+ break;
+ default:
+ /*
+ * discard packet
+ */
+ return s.str ();
+ }
+ }
+
+ switch (iph->protocol) {
+ case IPPROTO_IP:
+ s << getProtocol (iph->protocol) << " " << std::setw (15) << shost << " ==> " << std::setw (15) << dhost;
+ break;
+
+ case IPPROTO_ICMP:
+ s << getProtocol (iph->protocol) << " " << std::setw (15) << shost << " ==> " << std::setw (15) << dhost;
+
+ break;
+
+ case IPPROTO_TCP:
+ tcph = (struct tcphdr *)(str.c_str () + sizeof (struct ethhdr) + sizeof (struct iphdr));
+
+ sport = ntohs (tcph->source);
+ dport = ntohs (tcph->dest);
+
+ s << getProtocol (iph->protocol) << " "
+ << std::setw (15) << shost << ":" << std::setw (5) << sport
+ << " ==> " << std::setw (15) << dhost << ":" << std::setw (5) << dport;
+
+ if (tcph->urg)
+ s << (" urg ");
+ if (tcph->ack) {
+ s << (" ack ") << ntohl (tcph->ack_seq);
+ }
+ if (tcph->psh)
+ s << (" psh ");
+ if (tcph->rst)
+ s << (" rst ");
+ if (tcph->syn) {
+ s << (" syn ") << ntohl (tcph->seq);
+ }
+ if (tcph->fin)
+ s << (" fin ");
+
+ break;
+
+ case IPPROTO_UDP:
+ udph = (struct udphdr *)(str.c_str () + sizeof (struct ethhdr) + sizeof (struct iphdr));
+
+ sport = ntohs (udph->source);
+ dport = ntohs (udph->dest);
+
+ s << getProtocol (iph->protocol) << " "
+ << std::setw (15) << shost << ":" << std::setw (5) << sport
+ << " ==> " << std::setw (15) << dhost << ":" << std::setw (5) << dport;
+
+ break;
+
+ default:
+ s << getProtocol (iph->protocol);
+ break;
+ }
+
+ if (port != 0)
+ if ((sport != port) && (dport != port))
+ s.str ("");
+
+ return (s.str ());
+}
diff --git a/PacketReader.cpp b/PacketReader.cpp
new file mode 100644
--- /dev/null
+++ b/PacketReader.cpp
@@ -0,0 +1,63 @@
+/*
+ * $Id: PacketReader.cpp 54 2008-01-10 00:24:52Z mbroeker $
+ * $URL: http://localhost/svn/cpp/qMonitor/trunk/PacketReader.cpp $
+ */
+
+#include
+
+PacketReader::PacketReader (int tm)
+{
+ timeout = tm;
+
+ if ((p_socket = socket (PF_PACKET, SOCK_RAW, htons (ETH_P_ALL))) == -1) {
+ perror ("SocketException");
+ throw std::runtime_error ("SocketException: root access required");
+ }
+}
+
+PacketReader::PacketReader (std::string filename)
+{
+ if ((p_socket = open (filename.c_str (), O_RDONLY)) == -1) {
+ throw std::runtime_error ("FileException");
+ }
+
+ timeout = -1;
+}
+
+PacketReader::~PacketReader ()
+{
+ close (p_socket);
+}
+
+std::string PacketReader::read ()
+{
+ static char s[IP_MAXPACKET + 1];
+ int c;
+
+ c =::read (p_socket, s, IP_MAXPACKET);
+ s[c] = 0;
+ return std::string (s, c);
+}
+
+bool PacketReader::ready ()
+{
+ if (p_socket)
+ return true;
+
+ return false;
+}
+
+bool PacketReader::dataAvailable ()
+{
+ pollfd fdin;
+ int event = 1;
+
+ fdin.fd = p_socket;
+ fdin.events = POLLIN;
+ fdin.revents = 0;
+
+ if (poll (&fdin, event, timeout) > 0)
+ return true;
+
+ return false;
+}
diff --git a/PacketWriter.cpp b/PacketWriter.cpp
new file mode 100644
--- /dev/null
+++ b/PacketWriter.cpp
@@ -0,0 +1,48 @@
+/*
+ * $Id: PacketWriter.cpp 54 2008-01-10 00:24:52Z mbroeker $
+ * $URL: http://localhost/svn/cpp/qMonitor/trunk/PacketWriter.cpp $
+ */
+
+#include
+
+extern "C" {
+#include
+#include
+#include
+#include
+} PacketWriter::PacketWriter (char *hostname, int port)
+{
+ unsigned int size;
+ unsigned int fd;
+ struct hostent *host = gethostbyname (hostname);
+
+ if (host == NULL) {
+ perror ("GETHOSTBYNAME");
+ exit (0);
+ }
+
+ ca.sin_family = PF_INET;
+ ca.sin_addr = *((struct in_addr *)host->h_addr_list[0]);
+ ca.sin_port = htons (port);
+
+ size = sizeof (ca);
+ fd = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ p_socket = connect (fd, (sockaddr *) & ca, size);
+}
+
+PacketWriter::~PacketWriter ()
+{
+ close (p_socket);
+}
+
+void PacketWriter::write (char s[], int len)
+{
+ int c;
+
+ c =::write (p_socket, s, len);
+}
+
+bool PacketWriter::ready ()
+{
+ return true;
+}
diff --git a/build b/build
new file mode 100755
--- /dev/null
+++ b/build
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+# This works for qmake version 4.x and fails for qmake version 3 !
+#
+
+rm -rf .moc .obj Makefile
+find -name *~ -exec rm -f {} \;
+
+rm -f *.o
+qmake-qt4 -project .ui
+qmake-qt4 -makefile
+
+make all
+
+if [ ! -f /etc/gentoo-release ]
+then
+ ./post-install;
+else
+ echo "Skipping post-install, handled by ebuild";
+fi
+
diff --git a/debian/README.Debian b/debian/README.Debian
new file mode 100644
--- /dev/null
+++ b/debian/README.Debian
@@ -0,0 +1,6 @@
+qmonitor for Debian
+-------------------
+
+
+
+ -- Markus Broeker Fri, 07 Mar 2008 00:36:15 +0100
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,6 @@
+qmonitor (0.10-1) unstable; urgency=low
+
+ * Initial release (Closes: #nnnn)
+
+ -- Markus Broeker Fri, 07 Mar 2008 00:36:15 +0100
+
diff --git a/debian/compat b/debian/compat
new file mode 100644
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1,1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,12 @@
+Source: qmonitor
+Section: net
+Priority: extra
+Maintainer: Markus Broeker
+Build-Depends: debhelper (>= 5)
+Standards-Version: 3.7.2
+
+Package: qmonitor
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: qmonitor is a full featured network sniffer
+ qmonitor is a network sniffer written in qt
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,24 @@
+This package was debianized by Markus Broeker on
+Fri, 07 Mar 2008 00:36:15 +0100.
+
+It was downloaded from
+
+Upstream Author(s):
+
+
+
+
+Copyright:
+
+
+
+
+License:
+
+
+
+The Debian packaging is (C) 2008, Markus Broeker and
+is licensed under the GPL, see `/usr/share/common-licenses/GPL'.
+
+# Please also look if there are files or directories which have a
+# different copyright/license attached and list them here.
diff --git a/debian/dirs b/debian/dirs
new file mode 100644
--- /dev/null
+++ b/debian/dirs
@@ -0,0 +1,2 @@
+usr/share/icons
+usr/share/pixmaps
diff --git a/debian/rules b/debian/rules
new file mode 100755
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,93 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ # Add here commands to configure the package.
+
+ touch configure-stamp
+
+
+build: build-stamp
+
+build-stamp: configure-stamp
+ dh_testdir
+
+ # Add here commands to compile the package.
+ ./build
+ #docbook-to-man debian/qmonitor.sgml > qmonitor.1
+
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ # Add here commands to clean up after the build process.
+ if [ -f Makefile ]; then $(MAKE) distclean; fi
+ rm -f qmonitor qmonitor-0.10.pro
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/qmonitor.
+ mv qmonitor-0 qmonitor
+ install -d debian/qmonitor/usr/sbin/
+ install qmonitor debian/qmonitor/usr/sbin/
+ ./post-install;
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_installexamples
+# dh_install
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_python
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+ dh_installman
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+# dh_perl
+# dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/images/icon.png b/images/icon.png
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..dc313bc91d62d9771051782bf19d1f4fac0d141c
GIT binary patch
literal 214
zc%17D@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Y)RhkE)4%caKYZ?lYt_f1s;*b
z3=G`DAk4@xYmNj^kiEpy*OmP`BdfTuUM}M@S)hzopr0BFQN
Ang9R*
diff --git a/images/sideBar.png b/images/sideBar.png
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..18d1764872ae89f5c35f9a9f22313b00239e74cc
GIT binary patch
literal 11300
zc$@(wEZftGP)|E*vto_8kBKAOJ~3K~#8N?S1K!T-SBq>FH(m6_~+b-v~e?MG^!7QY1r}l1WBo
zGNK}fWy>x*Rj#s~@`qF^`Ib-l5Aro1QWd9MR;*Z+3Kfg0vSpE?rHG6~i4;W;+yIaS
zKoHwt_NBM{&VBdXzVG(yneLw6-o$=FD}wYzPeyc0I0W_8Q*a7I7ayem0wp=;akQ#>GPCQ-c=^Nb39F|Bu3R6&AYrE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#include
+#include
+#include
+#include
+#include
+}
+
+class PacketParser : public PacketReader
+{
+ public:
+ PacketParser ( int tm=500 );
+ PacketParser ( std::string );
+ ~PacketParser ();
+ std::string read();
+ std::string getPacket();
+ void setPort(unsigned short);
+ void setProtocol(int);
+ std::string getProtocol(int);
+
+ private:
+ std::string str;
+ int protocol;
+ unsigned short port;
+
+ std::string shost;
+ std::string dhost;
+ unsigned short sport, dport;
+ struct protoent *proto;
+};
+
+#endif
+
diff --git a/include/PacketReader.h b/include/PacketReader.h
new file mode 100644
--- /dev/null
+++ b/include/PacketReader.h
@@ -0,0 +1,37 @@
+/*
+ * $Id: PacketReader.h 2 2007-12-22 14:15:30Z mbroeker $
+ * $URL: http://localhost/svn/cpp/qMonitor/trunk/include/PacketReader.h $
+ */
+
+#ifndef PacketReader_H
+#define PacketReader_H
+
+#include
+#include
+#include
+
+extern "C" {
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+};
+
+class PacketReader {
+protected:
+ int p_socket;
+ private:
+ int timeout;
+public:
+ PacketReader ( int tm = 500 );
+ PacketReader ( std::string );
+ ~PacketReader();
+ std::string read();
+ bool ready();
+ bool dataAvailable();
+};
+
+#endif
diff --git a/include/PacketWriter.h b/include/PacketWriter.h
new file mode 100644
--- /dev/null
+++ b/include/PacketWriter.h
@@ -0,0 +1,28 @@
+/*
+ * $Id: PacketWriter.h 2 2007-12-22 14:15:30Z mbroeker $
+ * $URL: http://localhost/svn/cpp/qMonitor/trunk/include/PacketWriter.h $
+ */
+
+#ifndef PACKETWRITER_H
+#define PACKETWRITER_H 0x20053008
+#include
+
+#include
+#include
+#include
+#include
+
+class PacketWriter : PacketReader {
+private:
+ struct sockaddr_in ca;
+
+public:
+ PacketWriter(char *, int);
+ ~PacketWriter();
+
+ void write(char *s, int);
+ bool ready();
+};
+
+#endif
+
diff --git a/include/monitor.h b/include/monitor.h
new file mode 100644
--- /dev/null
+++ b/include/monitor.h
@@ -0,0 +1,38 @@
+/*
+ * $Id: monitor.h 2 2007-12-22 14:15:30Z mbroeker $
+ * $URL: http://localhost/svn/cpp/qMonitor/trunk/include/monitor.h $
+ */
+
+#ifndef MONITOR_H
+#define MONITOR_H
+
+#include
+#include
+#include "../ui_monitor.h"
+
+class readerThread;
+
+class Monitor : public QWidget, private Ui::qMonitor
+{
+ Q_OBJECT
+
+ public:
+ Monitor(QWidget *parent = 0);
+ virtual ~Monitor();
+ int getPort();
+ int getProtocol();
+
+ protected:
+ virtual void customEvent( QEvent* );
+ std::map Protocol;
+
+ private:
+ readerThread *reader;
+
+ public slots:
+ virtual void startCapture();
+ virtual void stopCapture();
+
+};
+
+#endif
diff --git a/include/readerthread.h b/include/readerthread.h
new file mode 100644
--- /dev/null
+++ b/include/readerthread.h
@@ -0,0 +1,40 @@
+/*
+ * $Id: readerthread.h 2 2007-12-22 14:15:30Z mbroeker $
+ * $URL: http://localhost/svn/cpp/qMonitor/trunk/include/readerthread.h $
+ */
+
+#ifndef READERTHREAD_H
+#define READERTHREAD_H
+
+#include "monitor.h"
+#include
+#include
+#include "PacketParser.h"
+
+#define MSG_EVENT 65432
+
+class Monitor;
+
+class DataChangeEvent : public QEvent {
+ public:
+ DataChangeEvent(QString msg_)
+ : QEvent((QEvent::Type)MSG_EVENT)
+ {
+ msg = msg_;
+
+ }
+
+ QString Text() const { return msg; }
+ private:
+ QString msg;
+};
+
+class readerThread : public QThread {
+ public:
+ readerThread(Monitor*);
+ virtual void run();
+ private:
+ Monitor *handle;
+};
+
+#endif
diff --git a/include/tools.h b/include/tools.h
new file mode 100644
--- /dev/null
+++ b/include/tools.h
@@ -0,0 +1,13 @@
+/*
+ * $Id: tools.h 2 2007-12-22 14:15:30Z mbroeker $
+ * $URL: http://localhost/svn/cpp/qMonitor/trunk/include/tools.h $
+ */
+
+#ifndef TOOLS_H
+#define TOOLS_H
+
+#include
+
+std::string itoa(const int& i);
+
+#endif
diff --git a/include/version.h b/include/version.h
new file mode 100644
--- /dev/null
+++ b/include/version.h
@@ -0,0 +1,11 @@
+/*
+ * $Id: version.h 2 2007-12-22 14:15:30Z mbroeker $
+ * $URL: http://localhost/svn/cpp/qMonitor/trunk/include/version.h $
+ */
+
+#ifndef VERSION_H
+#define VERSION_H
+
+#define VERSION_STRING "qMonitor Revision 0.90"
+#endif
+
diff --git a/main.cpp b/main.cpp
new file mode 100644
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,41 @@
+/*
+ * $Id: main.cpp 54 2008-01-10 00:24:52Z mbroeker $
+ * $URL: http://localhost/svn/cpp/qMonitor/trunk/main.cpp $
+ */
+
+#include
+
+#include "include/monitor.h"
+#include
+
+int main (int argc, char *argv[])
+{
+ int i;
+
+ while ((i = getopt (argc, argv, "hv")) >= 0) {
+ switch (i) {
+ case 'h':
+ std::cout << "Usage: " << argv[0] << " [OPTIONS]" << std::endl;
+ std::cout << "qMonitor displays the online traffic." << std::endl << std::endl;
+ std::cout << "Options:" << std::endl << std::endl;
+ std::cout << "-h: \t\t\tShow this help" << std::endl;
+ std::cout << "-v: \t\t\tShow Version" << std::endl;
+
+ exit (0);
+ break;
+ case 'v':
+ std::cout << VERSION_STRING << std::endl;
+ exit (0);
+ break;
+
+ default:
+ ;
+ }
+ }
+
+ QApplication app (argc, argv);
+ Monitor *dialog = new Monitor;
+
+ dialog->show ();
+ return app.exec ();
+}
diff --git a/man/man1/qMonitor.1 b/man/man1/qMonitor.1
new file mode 100644
--- /dev/null
+++ b/man/man1/qMonitor.1
@@ -0,0 +1,14 @@
+.\" qMonitor.1
+.TH qMonitor 1 "Feb. 2005" "Markus Broeker"
+.SH Name
+qMonitor \- Ein qt-basierender Netzwerkmonitor
+.SH SYNTAX
+qMonitor
+.SH BESCHREIBUNG
+.fi
+Der auf qt-basierende Netzwerkmonitor \fBqMonitor\fR zeigt ihnen den
+Traffic im Netz an.
+.nf
+.SH AUTOR
+Markus Broker ( broeker.markus@freenet.de )
+
diff --git a/monitor.cpp b/monitor.cpp
new file mode 100644
--- /dev/null
+++ b/monitor.cpp
@@ -0,0 +1,104 @@
+/*
+ * $Id: monitor.cpp 54 2008-01-10 00:24:52Z mbroeker $
+ * $URL: http://localhost/svn/cpp/qMonitor/trunk/monitor.cpp $
+ */
+
+#include "include/monitor.h"
+#include "include/readerthread.h"
+
+#ifndef ICON_PATH
+#define ICON_PATH "/usr/share/icons/qMonitor_icon.png"
+#endif
+
+#define HTML_MESSAGE \
+"qMonitor
" \
+"" \
+"
Wählen Sie das Protokoll" \
+"Wählen Sie einen Port (0=ALLE)" \
+"Drücken Sie Start" \
+"
" \
+"Dieses Programm zeigt den Traffic im Netz an und unterstützt Sie bei täglichen Aufgaben:
" \
+"Kontrolle der TCP/UDP Verbindungen" \
+"Überwachung von textbasierten Serverdiensten" \
+"Protokollanalyse" \
+""
+
+Monitor::Monitor (QWidget * parent)
+{
+ setupUi ((QDialog *) this);
+ textEdit->setReadOnly (true);
+
+ listWidget1->insertItem (0, "TCP");
+ listWidget1->insertItem (1, "UDP");
+ listWidget1->insertItem (2, "ICMP");
+ listWidget1->insertItem (3, "RAW");
+ listWidget1->insertItem (4, "IP");
+
+ Protocol["TCP"] = IPPROTO_TCP;
+ Protocol["UDP"] = IPPROTO_UDP;
+ Protocol["ICMP"] = IPPROTO_ICMP;
+ Protocol["RAW"] = IPPROTO_RAW;
+ Protocol["IP"] = IPPROTO_IP;
+
+ listWidget1->setCurrentRow (0);
+ lineEdit1->setText ("0");
+
+ setWindowIcon (QPixmap (ICON_PATH));
+
+ textEdit->insertHtml (HTML_MESSAGE);
+
+ try {
+ reader = new readerThread (this);
+ }
+ catch (std::exception const &e) {
+ textEdit->append (e.what ());
+ reader = NULL;
+ }
+
+ connect (pushButton1, SIGNAL (clicked ()), this, SLOT (startCapture ()));
+ connect (pushButton2, SIGNAL (clicked ()), this, SLOT (stopCapture ()));
+
+}
+
+Monitor::~Monitor ()
+{
+ if (reader != NULL)
+ delete reader;
+}
+
+void Monitor::startCapture ()
+{
+ textEdit->clear ();
+
+ if (reader != NULL) {
+ if (!reader->isRunning ())
+ reader->start (QThread::NormalPriority);
+ }
+}
+
+void Monitor::stopCapture ()
+{
+ if (reader != NULL) {
+ if (reader->isRunning ())
+ reader->terminate ();
+ }
+}
+
+int Monitor::getProtocol ()
+{
+ return Protocol[listWidget1->item (listWidget1->currentRow ())->text ()];
+}
+
+int Monitor::getPort ()
+{
+ return lineEdit1->text ().toInt ();
+}
+
+void Monitor::customEvent (QEvent * e)
+{
+ if (e->type () == MSG_EVENT) {
+ DataChangeEvent *me = (DataChangeEvent *) e;
+
+ textEdit->append (me->Text ());
+ }
+}
diff --git a/post-install b/post-install
new file mode 100755
--- /dev/null
+++ b/post-install
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+PDIRECTORY=/usr/share/pixmaps
+IDIRECTORY=/usr/share/icons
+
+FILE=qMonitor_sideBar.png
+ICON=qMonitor_icon.png
+
+echo -n "Checking, whether ${PDIRECTORY} exists... [ "
+if [ ! -d ${PDIRECTORY} ]
+then
+ install -d ${PDIRECTORY};
+ echo "creating ]";
+else
+ echo "yes ]";
+fi
+
+echo -n "Checking, whether ${PDIRECTORY}/${FILE} exists... [ "
+if [ ! -r ${PDIRECTORY}/${FILE} ]
+then
+ install -m 644 images/sideBar.png \
+ ${PDIRECTORY}/${FILE};
+ echo "installing ]"
+ else
+ echo "yes ]";
+fi
+
+echo -n "Checking, whether ${IDIRECTORY} exists... [ "
+if [ ! -d ${IDIRECTORY} ]
+then
+ install -d ${IDIRECTORY};
+ echo "creating ]";
+else
+ echo "yes ]";
+fi
+
+echo -n "Checking, whether ${IDIRECTORY}/${ICON} exists... [ "
+if [ ! -r ${IDIRECTORY}/${ICON} ]
+then
+ install -m 644 images/icon.png \
+ ${IDIRECTORY}/${ICON};
+ echo "installing ]"
+ else
+ echo "yes ]";
+fi
diff --git a/readerthread.cpp b/readerthread.cpp
new file mode 100644
--- /dev/null
+++ b/readerthread.cpp
@@ -0,0 +1,41 @@
+/*
+ * $Id: readerthread.cpp 54 2008-01-10 00:24:52Z mbroeker $
+ * $URL: http://localhost/svn/cpp/qMonitor/trunk/readerthread.cpp $
+ */
+
+#include "include/readerthread.h"
+#include
+
+readerThread::readerThread (Monitor * parent)
+{
+ handle = parent;
+}
+
+void readerThread::run ()
+{
+ std::string s;
+ DataChangeEvent *dce;
+
+ try {
+ PacketParser reader (-1);
+
+ for (;;) {
+ while (reader.dataAvailable ()) {
+ reader.setProtocol (handle->getProtocol ());
+ reader.setPort (handle->getPort ());
+
+ s = reader.read ();
+
+ if (s != "") {
+ dce = new DataChangeEvent (s.c_str ());
+ QApplication::postEvent ((QObject *) handle, (QEvent *) dce);
+ }
+ }
+ }
+ }
+ catch (std::exception const &e) {
+ dce = new DataChangeEvent (e.what ());
+ QApplication::postEvent ((QObject *) handle, (QEvent *) dce);
+ std::cerr << e.what () << std::endl;
+ }
+}
diff --git a/tools.cpp b/tools.cpp
new file mode 100644
--- /dev/null
+++ b/tools.cpp
@@ -0,0 +1,15 @@
+/*
+ * $Id: tools.cpp 54 2008-01-10 00:24:52Z mbroeker $
+ * $URL: http://localhost/svn/cpp/qMonitor/trunk/tools.cpp $
+ */
+
+#include
+
+std::string itoa (const int &i)
+{
+ std::stringstream o;
+
+ if (!(o << i))
+ return "ERROR";
+ return o.str ();
+}