summaryrefslogtreecommitdiffstats
path: root/workspace/LogReceiver
diff options
context:
space:
mode:
authorNiklas2011-07-06 16:56:16 +0200
committerNiklas2011-07-06 16:56:16 +0200
commite71f5ac6630686f3bd92817b401ed8d88e121f6d (patch)
tree13f6a33a630f61aa0b259c0b302b8ae203058bc0 /workspace/LogReceiver
parentnew funtions for the networkDiscovery class. (diff)
downloadfbgui-e71f5ac6630686f3bd92817b401ed8d88e121f6d.tar.gz
fbgui-e71f5ac6630686f3bd92817b401ed8d88e121f6d.tar.xz
fbgui-e71f5ac6630686f3bd92817b401ed8d88e121f6d.zip
added the two tryout with a qt LogReceiver and a c code client
Diffstat (limited to 'workspace/LogReceiver')
-rwxr-xr-xworkspace/LogReceiver/LogReceiverbin0 -> 30954 bytes
-rw-r--r--workspace/LogReceiver/LogReceiver.pro10
-rw-r--r--workspace/LogReceiver/logreceiver.cpp70
-rw-r--r--workspace/LogReceiver/logreceiver.h34
-rw-r--r--workspace/LogReceiver/logreceiver.ui19
-rw-r--r--workspace/LogReceiver/main.cpp12
6 files changed, 145 insertions, 0 deletions
diff --git a/workspace/LogReceiver/LogReceiver b/workspace/LogReceiver/LogReceiver
new file mode 100755
index 0000000..16bcf4b
--- /dev/null
+++ b/workspace/LogReceiver/LogReceiver
Binary files differ
diff --git a/workspace/LogReceiver/LogReceiver.pro b/workspace/LogReceiver/LogReceiver.pro
new file mode 100644
index 0000000..3a2d3f9
--- /dev/null
+++ b/workspace/LogReceiver/LogReceiver.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+TARGET = LogReceiver
+
+QT += core gui network
+
+HEADERS += logreceiver.h
+SOURCES += main.cpp \
+ logreceiver.cpp
+FORMS += logreceiver.ui
+RESOURCES +=
diff --git a/workspace/LogReceiver/logreceiver.cpp b/workspace/LogReceiver/logreceiver.cpp
new file mode 100644
index 0000000..9bca304
--- /dev/null
+++ b/workspace/LogReceiver/logreceiver.cpp
@@ -0,0 +1,70 @@
+ #include <QtGui>
+ #include <QtNetwork>
+
+ #include <stdlib.h>
+
+ #include "logreceiver.h"
+ #include <qlocalserver.h>
+ #include <qlocalsocket.h>
+
+
+LogReceiver::LogReceiver(QWidget *parent) :
+ QDialog(parent) {
+ ui.setupUi(this);
+
+ statusLabel = new QLabel;
+ quitButton = new QPushButton(tr("Quit"));
+ quitButton->setAutoDefault(false);
+
+ server = new QLocalServer(this);
+ if (!server->listen("/var/tmp/qt_c_socket_test")) {
+ QMessageBox::critical(this, tr("LogReceiver"), tr(
+ "Unable to start the server: %1.") .arg(server->errorString()));
+ close();
+ return;
+ }
+
+ statusLabel->setText(tr("The server is running.\n"
+ "Run the C Client example now."));
+
+ connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
+ connect(server, SIGNAL(newConnection()), this, SLOT(handleNewConnection()));
+
+ QHBoxLayout *buttonLayout = new QHBoxLayout;
+ buttonLayout->addStretch(1);
+ buttonLayout->addWidget(quitButton);
+ buttonLayout->addStretch(1);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(statusLabel);
+ mainLayout->addLayout(buttonLayout);
+ setLayout(mainLayout);
+
+ setWindowTitle(tr("Fortune Server"));
+}
+
+LogReceiver::~LogReceiver() {
+
+}
+
+
+ void LogReceiver::handleNewConnection()
+ {
+ qDebug() << "New Connection arrived";
+
+ clientSocket = server->nextPendingConnection();
+ connect(clientSocket, SIGNAL(disconnected()),
+ clientSocket, SLOT(deleteLater()));
+ connect(clientSocket, SIGNAL(readyRead()), this, SLOT(handleNewInput()));
+ }
+
+ void LogReceiver::handleNewInput() {
+
+ QByteArray data = clientSocket->readAll();
+
+ QString logMsg(data);
+ qDebug() << logMsg;
+
+ statusLabel->setText(logMsg);
+}
+
diff --git a/workspace/LogReceiver/logreceiver.h b/workspace/LogReceiver/logreceiver.h
new file mode 100644
index 0000000..6b94eab
--- /dev/null
+++ b/workspace/LogReceiver/logreceiver.h
@@ -0,0 +1,34 @@
+#ifndef LOGRECEIVER_H
+#define LOGRECEIVER_H
+
+#include <QDialog>
+#include <QtGui/QWidget>
+#include "ui_logreceiver.h"
+
+class QLabel;
+class QPushButton;
+class QLocalServer;
+class QLocalSocket;
+
+class LogReceiver: public QDialog {
+Q_OBJECT
+
+public:
+ LogReceiver(QWidget *parent = 0);
+ ~LogReceiver();
+
+private slots:
+ void handleNewConnection();
+ void handleNewInput();
+
+private:
+ Ui::LogReceiverClass ui;
+ QLabel *statusLabel;
+ QPushButton *quitButton;
+ QLocalServer *server;
+ QStringList fortunes;
+ QLocalSocket *clientSocket;
+ quint16 blockSize;
+};
+
+#endif // LOGRECEIVER_H
diff --git a/workspace/LogReceiver/logreceiver.ui b/workspace/LogReceiver/logreceiver.ui
new file mode 100644
index 0000000..9143194
--- /dev/null
+++ b/workspace/LogReceiver/logreceiver.ui
@@ -0,0 +1,19 @@
+<ui version="4.0" >
+ <class>LogReceiverClass</class>
+ <widget class="QWidget" name="LogReceiverClass" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>LogReceiver</string>
+ </property>
+ </widget>
+ <layoutdefault spacing="6" margin="11" />
+ <resources/>
+ <connections/>
+</ui>
diff --git a/workspace/LogReceiver/main.cpp b/workspace/LogReceiver/main.cpp
new file mode 100644
index 0000000..e545906
--- /dev/null
+++ b/workspace/LogReceiver/main.cpp
@@ -0,0 +1,12 @@
+#include "logreceiver.h"
+
+#include <QtGui>
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ LogReceiver w;
+ w.show();
+ return a.exec();
+}