Port common, rpc and client code to Qt5
Still pending * server port to Qt5 * verify/test the port
This commit is contained in:
parent
b6c46e27e9
commit
f801982830
@ -138,14 +138,17 @@ QVariant ArpStatusModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
void ArpStatusModel::setDeviceIndex(Port *port, int deviceIndex)
|
void ArpStatusModel::setDeviceIndex(Port *port, int deviceIndex)
|
||||||
{
|
{
|
||||||
|
beginResetModel();
|
||||||
port_ = port;
|
port_ = port;
|
||||||
deviceIndex_ = deviceIndex;
|
deviceIndex_ = deviceIndex;
|
||||||
if (port_)
|
if (port_)
|
||||||
neighbors_ = port_->deviceNeighbors(deviceIndex);
|
neighbors_ = port_->deviceNeighbors(deviceIndex);
|
||||||
reset();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArpStatusModel::updateArpStatus()
|
void ArpStatusModel::updateArpStatus()
|
||||||
{
|
{
|
||||||
reset();
|
// FIXME: why needed?
|
||||||
|
beginResetModel();
|
||||||
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ DeviceGroupDialog::DeviceGroupDialog(
|
|||||||
vlans->setItemDelegateForColumn(i, spd);
|
vlans->setItemDelegateForColumn(i, spd);
|
||||||
}
|
}
|
||||||
|
|
||||||
vlans->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
|
vlans->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||||
vlans->resizeRowsToContents();
|
vlans->resizeRowsToContents();
|
||||||
|
|
||||||
// Set vlan tag count *after* adding all items, so connected slots
|
// Set vlan tag count *after* adding all items, so connected slots
|
||||||
|
@ -257,8 +257,9 @@ bool DeviceGroupModel::removeRows(
|
|||||||
|
|
||||||
void DeviceGroupModel::setPort(Port *port)
|
void DeviceGroupModel::setPort(Port *port)
|
||||||
{
|
{
|
||||||
|
beginResetModel();
|
||||||
port_ = port;
|
port_ = port;
|
||||||
reset();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -243,10 +243,11 @@ QVariant DeviceModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
void DeviceModel::setPort(Port *port)
|
void DeviceModel::setPort(Port *port)
|
||||||
{
|
{
|
||||||
|
beginResetModel();
|
||||||
port_ = port;
|
port_ = port;
|
||||||
if (port_)
|
if (port_)
|
||||||
connect(port_, SIGNAL(deviceInfoChanged()), SLOT(updateDeviceList()));
|
connect(port_, SIGNAL(deviceInfoChanged()), SLOT(updateDeviceList()));
|
||||||
reset();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
QAbstractItemModel* DeviceModel::detailModel(const QModelIndex &index)
|
QAbstractItemModel* DeviceModel::detailModel(const QModelIndex &index)
|
||||||
@ -268,7 +269,8 @@ QAbstractItemModel* DeviceModel::detailModel(const QModelIndex &index)
|
|||||||
|
|
||||||
void DeviceModel::updateDeviceList()
|
void DeviceModel::updateDeviceList()
|
||||||
{
|
{
|
||||||
reset();
|
beginResetModel();
|
||||||
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Style roles for drillable fields
|
// Style roles for drillable fields
|
||||||
|
@ -19,6 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include "dumpview.h"
|
#include "dumpview.h"
|
||||||
|
|
||||||
|
#include <QScrollBar>
|
||||||
|
#include <QStylePainter>
|
||||||
|
|
||||||
//! \todo Enable Scrollbars
|
//! \todo Enable Scrollbars
|
||||||
|
|
||||||
DumpView::DumpView(QWidget *parent)
|
DumpView::DumpView(QWidget *parent)
|
||||||
|
@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtGui> // FIXME: High
|
#include <QAbstractItemView>
|
||||||
|
|
||||||
|
|
||||||
class DumpView: public QAbstractItemView
|
class DumpView: public QAbstractItemView
|
||||||
|
@ -64,10 +64,10 @@ void HexLineEdit::focusOutEvent(QFocusEvent* /*e*/)
|
|||||||
bool isOk;
|
bool isOk;
|
||||||
ulong num;
|
ulong num;
|
||||||
|
|
||||||
qDebug("before = %s\n", text().toAscii().data());
|
qDebug("before = %s\n", qPrintable(text()));
|
||||||
num = text().remove(QChar(' ')).toULong(&isOk, 16);
|
num = text().remove(QChar(' ')).toULong(&isOk, 16);
|
||||||
setText(uintToHexStr(num, 4));
|
setText(uintToHexStr(num, 4));
|
||||||
qDebug("after = %s\n", text().toAscii().data());
|
qDebug("after = %s\n", qPrintable(text()));
|
||||||
#undef uintToHexStr
|
#undef uintToHexStr
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -142,14 +142,17 @@ QVariant NdpStatusModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
void NdpStatusModel::setDeviceIndex(Port *port, int deviceIndex)
|
void NdpStatusModel::setDeviceIndex(Port *port, int deviceIndex)
|
||||||
{
|
{
|
||||||
|
beginResetModel();
|
||||||
port_ = port;
|
port_ = port;
|
||||||
deviceIndex_ = deviceIndex;
|
deviceIndex_ = deviceIndex;
|
||||||
if (port_)
|
if (port_)
|
||||||
neighbors_ = port_->deviceNeighbors(deviceIndex);
|
neighbors_ = port_->deviceNeighbors(deviceIndex);
|
||||||
reset();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NdpStatusModel::updateNdpStatus()
|
void NdpStatusModel::updateNdpStatus()
|
||||||
{
|
{
|
||||||
reset();
|
// FIXME: why needed?
|
||||||
|
beginResetModel();
|
||||||
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ CONFIG += qt ver_info
|
|||||||
macx: TARGET = Ostinato
|
macx: TARGET = Ostinato
|
||||||
win32:RC_FILE = ostinato.rc
|
win32:RC_FILE = ostinato.rc
|
||||||
macx:ICON = icons/logo.icns
|
macx:ICON = icons/logo.icns
|
||||||
QT += network script xml
|
QT += widgets network script xml
|
||||||
INCLUDEPATH += "../rpc/" "../common/"
|
INCLUDEPATH += "../rpc/" "../common/"
|
||||||
win32 {
|
win32 {
|
||||||
QMAKE_LFLAGS += -static
|
QMAKE_LFLAGS += -static
|
||||||
|
@ -38,8 +38,9 @@ void PacketModel::setSelectedProtocols(ProtocolListIterator &iter)
|
|||||||
|
|
||||||
if (mSelectedProtocols != currentProtocols)
|
if (mSelectedProtocols != currentProtocols)
|
||||||
{
|
{
|
||||||
|
beginResetModel();
|
||||||
mSelectedProtocols = currentProtocols;
|
mSelectedProtocols = currentProtocols;
|
||||||
reset();
|
endResetModel();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1412,7 +1412,7 @@ void PortGroup::viewCapture(QList<uint> *portList)
|
|||||||
portId->set_id(portList->at(i));
|
portId->set_id(portList->at(i));
|
||||||
|
|
||||||
capFile->open(QIODevice::ReadWrite|QIODevice::Truncate);
|
capFile->open(QIODevice::ReadWrite|QIODevice::Truncate);
|
||||||
qDebug("Temp CapFile = %s", capFile->fileName().toAscii().constData());
|
qDebug("Temp CapFile = %s", qPrintable(capFile->fileName()));
|
||||||
controller->setBinaryBlob(capFile);
|
controller->setBinaryBlob(capFile);
|
||||||
|
|
||||||
serviceStub->getCaptureBuffer(controller, portId, buf,
|
serviceStub->getCaptureBuffer(controller, portId, buf,
|
||||||
|
@ -343,5 +343,7 @@ void PortModel::portGroupRemoved()
|
|||||||
|
|
||||||
void PortModel::when_portListChanged()
|
void PortModel::when_portListChanged()
|
||||||
{
|
{
|
||||||
reset();
|
// FIXME: why needed?
|
||||||
|
beginResetModel();
|
||||||
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
@ -308,6 +308,8 @@ void PortStatsModel::when_portListChanged()
|
|||||||
{
|
{
|
||||||
int i, count = 0;
|
int i, count = 0;
|
||||||
|
|
||||||
|
beginResetModel();
|
||||||
|
|
||||||
// recalc numPorts
|
// recalc numPorts
|
||||||
while (numPorts.size())
|
while (numPorts.size())
|
||||||
numPorts.removeFirst();
|
numPorts.removeFirst();
|
||||||
@ -318,7 +320,7 @@ void PortStatsModel::when_portListChanged()
|
|||||||
numPorts.append(count);
|
numPorts.append(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
reset();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: unused? if used, the index calculation row/column needs to be swapped
|
// FIXME: unused? if used, the index calculation row/column needs to be swapped
|
||||||
|
@ -846,7 +846,7 @@ void PortsWindow::on_actionDuplicate_Stream_triggered()
|
|||||||
if (model->hasSelection())
|
if (model->hasSelection())
|
||||||
{
|
{
|
||||||
bool isOk;
|
bool isOk;
|
||||||
int count = QInputDialog::getInteger(this, "Duplicate Streams",
|
int count = QInputDialog::getInt(this, "Duplicate Streams",
|
||||||
"Count", 1, 1, 9999, 1, &isOk);
|
"Count", 1, 1, 9999, 1, &isOk);
|
||||||
|
|
||||||
if (!isOk)
|
if (!isOk)
|
||||||
|
@ -30,6 +30,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "../common/protocolmanager.h"
|
#include "../common/protocolmanager.h"
|
||||||
#include "../common/protocolwidgetfactory.h"
|
#include "../common/protocolwidgetfactory.h"
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
extern ProtocolManager *OstProtocolManager;
|
extern ProtocolManager *OstProtocolManager;
|
||||||
extern ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
extern ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
||||||
|
|
||||||
@ -429,7 +431,7 @@ void StreamConfigDialog::on_cmbPktLenMode_currentIndexChanged(QString mode)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qWarning("Unhandled/Unknown PktLenMode = %s", mode.toAscii().data());
|
qWarning("Unhandled/Unknown PktLenMode = %s", qPrintable(mode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -710,9 +712,9 @@ void StreamConfigDialog::on_lePattern_editingFinished()
|
|||||||
QString str;
|
QString str;
|
||||||
|
|
||||||
num = lePattern->text().remove(QChar(' ')).toULong(&isOk, 16);
|
num = lePattern->text().remove(QChar(' ')).toULong(&isOk, 16);
|
||||||
qDebug("editfinished (%s | %x)\n", lePattern->text().toAscii().data(), num);
|
qDebug("editfinished (%s | %x)\n", qPrintable(lePattern->text()));
|
||||||
lePattern->setText(uintToHexStr(num, str, 4));
|
lePattern->setText(uintToHexStr(num, str, 4));
|
||||||
qDebug("editfinished (%s | %x)\n", lePattern->text().toAscii().data(), num);
|
qDebug("editfinished (%s | %x)\n", qPrintable(lePattern->text()));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1186,7 +1188,7 @@ void StreamConfigDialog::on_leBurstsPerSec_textChanged(const QString &text)
|
|||||||
uint burstSize = lePacketsPerBurst->text().toULong(&isOk);
|
uint burstSize = lePacketsPerBurst->text().toULong(&isOk);
|
||||||
uint frameLen;
|
uint frameLen;
|
||||||
|
|
||||||
qDebug("start of %s(%s)", __FUNCTION__, text.toAscii().constData());
|
qDebug("start of %s(%s)", __FUNCTION__, qPrintable(text));
|
||||||
if (pStream->lenMode() == Stream::e_fl_fixed)
|
if (pStream->lenMode() == Stream::e_fl_fixed)
|
||||||
frameLen = pStream->frameLen();
|
frameLen = pStream->frameLen();
|
||||||
else
|
else
|
||||||
|
@ -27,6 +27,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "packetmodel.h"
|
#include "packetmodel.h"
|
||||||
#include "modeltest.h"
|
#include "modeltest.h"
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QProgressDialog>
|
||||||
|
#include <QStringListModel>
|
||||||
|
|
||||||
#define MAX_MAC_ITER_COUNT 256
|
#define MAX_MAC_ITER_COUNT 256
|
||||||
#define MIN_PKT_LEN 64
|
#define MIN_PKT_LEN 64
|
||||||
#define MAX_PKT_LEN 16384
|
#define MAX_PKT_LEN 16384
|
||||||
|
@ -177,7 +177,7 @@ bool StreamListDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
|
|||||||
if ((event->type() == QEvent::MouseButtonRelease)
|
if ((event->type() == QEvent::MouseButtonRelease)
|
||||||
|| (event->type() == QEvent::MouseButtonDblClick))
|
|| (event->type() == QEvent::MouseButtonDblClick))
|
||||||
{
|
{
|
||||||
QRect checkRect = check(option, option.rect, Qt::Checked);
|
QRect checkRect = doCheck(option, option.rect, Qt::Checked);
|
||||||
QRect emptyRect;
|
QRect emptyRect;
|
||||||
doLayout(option, &checkRect, &emptyRect, &emptyRect, false);
|
doLayout(option, &checkRect, &emptyRect, &emptyRect, false);
|
||||||
if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))
|
if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))
|
||||||
|
@ -277,6 +277,7 @@ bool StreamModel::removeRows(int row, int count, const QModelIndex &/*parent*/)
|
|||||||
|
|
||||||
void StreamModel::setCurrentPortIndex(const QModelIndex ¤t)
|
void StreamModel::setCurrentPortIndex(const QModelIndex ¤t)
|
||||||
{
|
{
|
||||||
|
beginResetModel();
|
||||||
if (!current.isValid() || !pgl->isPort(current))
|
if (!current.isValid() || !pgl->isPort(current))
|
||||||
{
|
{
|
||||||
qDebug("current is either invalid or not a port");
|
qDebug("current is either invalid or not a port");
|
||||||
@ -298,7 +299,7 @@ void StreamModel::setCurrentPortIndex(const QModelIndex ¤t)
|
|||||||
connect(mCurrentPort, SIGNAL(streamListChanged(int, int)),
|
connect(mCurrentPort, SIGNAL(streamListChanged(int, int)),
|
||||||
this, SLOT(when_mCurrentPort_streamListChanged(int, int)));
|
this, SLOT(when_mCurrentPort_streamListChanged(int, int)));
|
||||||
}
|
}
|
||||||
reset();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamModel::when_mCurrentPort_streamListChanged(int portGroupId,
|
void StreamModel::when_mCurrentPort_streamListChanged(int portGroupId,
|
||||||
@ -309,6 +310,9 @@ void StreamModel::when_mCurrentPort_streamListChanged(int portGroupId,
|
|||||||
{
|
{
|
||||||
if ((quint32(portGroupId) == mCurrentPort->portGroupId())
|
if ((quint32(portGroupId) == mCurrentPort->portGroupId())
|
||||||
&& (quint32(portId) == mCurrentPort->id()))
|
&& (quint32(portId) == mCurrentPort->id()))
|
||||||
reset();
|
{
|
||||||
|
beginResetModel();
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
#if 0 // FIXME: Test and remove
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
#error "Do we even need this anymore?"
|
#error "Do we even need this anymore?"
|
||||||
#endif
|
#endif
|
||||||
@ -45,6 +46,9 @@ private:
|
|||||||
QTreeView::mousePressEvent(event);
|
QTreeView::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
typedef QTreeView XTreeView;
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -620,9 +620,9 @@ QByteArray AbstractProtocol::protocolFrameValue(int streamIndex, bool forCksum)
|
|||||||
else
|
else
|
||||||
field = fieldData(i, FieldFrameValue, streamIndex).toByteArray();
|
field = fieldData(i, FieldFrameValue, streamIndex).toByteArray();
|
||||||
qDebug("<<< (%d, %db) %s >>>", proto.size(), lastbitpos,
|
qDebug("<<< (%d, %db) %s >>>", proto.size(), lastbitpos,
|
||||||
QString(proto.toHex()).toAscii().constData());
|
qPrintable(QString(proto.toHex())));
|
||||||
qDebug(" < %d: (%db/%dB) %s >", i, bits, field.size(),
|
qDebug(" < %d: (%db/%dB) %s >", i, bits, field.size(),
|
||||||
QString(field.toHex()).toAscii().constData());
|
qPrintable(QString(field.toHex())));
|
||||||
|
|
||||||
if (bits == (uint) field.size() * 8)
|
if (bits == (uint) field.size() * 8)
|
||||||
{
|
{
|
||||||
|
@ -94,7 +94,7 @@ void PdmlIcmp6Protocol::unknownFieldHandler(QString name,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug("unexpected field %s", name.toAscii().constData());
|
qDebug("unexpected field %s", qPrintable(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ bool NativeFileFormat::open(
|
|||||||
qDebug("%s: size = %d", __FUNCTION__, size);
|
qDebug("%s: size = %d", __FUNCTION__, size);
|
||||||
|
|
||||||
//qDebug("Read %d bytes", buf.size());
|
//qDebug("Read %d bytes", buf.size());
|
||||||
//qDebug("%s", QString(buf.toHex()).toAscii().constData());
|
//qDebug("%s", qPrintable(QString(buf.toHex())));
|
||||||
|
|
||||||
// Parse and verify magic
|
// Parse and verify magic
|
||||||
if (!magic.ParseFromArray(
|
if (!magic.ParseFromArray(
|
||||||
@ -148,7 +148,7 @@ bool NativeFileFormat::open(
|
|||||||
}
|
}
|
||||||
|
|
||||||
qDebug("%s: File MetaData (INFORMATION) - \n%s", __FUNCTION__,
|
qDebug("%s: File MetaData (INFORMATION) - \n%s", __FUNCTION__,
|
||||||
QString().fromStdString(meta.DebugString()).toAscii().constData());
|
meta.DebugString().c_str());
|
||||||
qDebug("%s: END MetaData", __FUNCTION__);
|
qDebug("%s: END MetaData", __FUNCTION__);
|
||||||
|
|
||||||
// MetaData Validation(s)
|
// MetaData Validation(s)
|
||||||
@ -193,11 +193,8 @@ bool NativeFileFormat::open(
|
|||||||
|
|
||||||
_content_parse_fail:
|
_content_parse_fail:
|
||||||
error = QString(tr("Failed parsing %1 contents")).arg(fileName);
|
error = QString(tr("Failed parsing %1 contents")).arg(fileName);
|
||||||
qDebug("Error: %s", QString().fromStdString(
|
qDebug("Error: %s", content.InitializationErrorString().c_str());
|
||||||
content.InitializationErrorString())
|
qDebug("Debug: %s", content.DebugString().c_str());
|
||||||
.toAscii().constData());
|
|
||||||
qDebug("Debug: %s", QString().fromStdString(
|
|
||||||
content.DebugString()).toAscii().constData());
|
|
||||||
goto _fail;
|
goto _fail;
|
||||||
_incompatible_file_version:
|
_incompatible_file_version:
|
||||||
error = QString(tr("%1 is in an incompatible format version - %2.%3.%4"
|
error = QString(tr("%1 is in an incompatible format version - %2.%3.%4"
|
||||||
@ -217,9 +214,7 @@ _unexpected_file_type:
|
|||||||
goto _fail;
|
goto _fail;
|
||||||
_metadata_parse_fail:
|
_metadata_parse_fail:
|
||||||
error = QString(tr("Failed parsing %1 meta data")).arg(fileName);
|
error = QString(tr("Failed parsing %1 meta data")).arg(fileName);
|
||||||
qDebug("Error: %s", QString().fromStdString(
|
qDebug("Error: %s", meta.data().InitializationErrorString().c_str());
|
||||||
meta.data().InitializationErrorString())
|
|
||||||
.toAscii().constData());
|
|
||||||
goto _fail;
|
goto _fail;
|
||||||
_cksum_verify_fail:
|
_cksum_verify_fail:
|
||||||
error = QString(tr("%1 checksum validation failed!\nExpected:%2 Actual:%3"))
|
error = QString(tr("%1 checksum validation failed!\nExpected:%2 Actual:%3"))
|
||||||
@ -236,18 +231,14 @@ _zero_cksum_serialize_fail:
|
|||||||
goto _fail;
|
goto _fail;
|
||||||
_cksum_parse_fail:
|
_cksum_parse_fail:
|
||||||
error = QString(tr("Failed parsing %1 checksum")).arg(fileName);
|
error = QString(tr("Failed parsing %1 checksum")).arg(fileName);
|
||||||
qDebug("Error: %s", QString().fromStdString(
|
qDebug("Error: %s", cksum.InitializationErrorString().c_str());
|
||||||
cksum.InitializationErrorString())
|
|
||||||
.toAscii().constData());
|
|
||||||
goto _fail;
|
goto _fail;
|
||||||
_magic_match_fail:
|
_magic_match_fail:
|
||||||
error = QString(tr("%1 is not an Ostinato file")).arg(fileName);
|
error = QString(tr("%1 is not an Ostinato file")).arg(fileName);
|
||||||
goto _fail;
|
goto _fail;
|
||||||
_magic_parse_fail:
|
_magic_parse_fail:
|
||||||
error = QString(tr("%1 does not look like an Ostinato file")).arg(fileName);
|
error = QString(tr("%1 does not look like an Ostinato file")).arg(fileName);
|
||||||
qDebug("Error: %s", QString().fromStdString(
|
qDebug("Error: %s", magic.InitializationErrorString().c_str());
|
||||||
magic.InitializationErrorString())
|
|
||||||
.toAscii().constData());
|
|
||||||
goto _fail;
|
goto _fail;
|
||||||
_read_fail:
|
_read_fail:
|
||||||
error = QString(tr("Error reading from %1")).arg(fileName);
|
error = QString(tr("Error reading from %1")).arg(fileName);
|
||||||
@ -263,7 +254,7 @@ _open_fail:
|
|||||||
error = QString(tr("Error opening %1")).arg(fileName);
|
error = QString(tr("Error opening %1")).arg(fileName);
|
||||||
goto _fail;
|
goto _fail;
|
||||||
_fail:
|
_fail:
|
||||||
qDebug("%s", error.toAscii().constData());
|
qDebug("%s", qPrintable(error));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +335,7 @@ bool NativeFileFormat::save(
|
|||||||
}
|
}
|
||||||
|
|
||||||
qDebug("Writing %d bytes", buf.size());
|
qDebug("Writing %d bytes", buf.size());
|
||||||
//qDebug("%s", QString(buf.toHex()).toAscii().constData());
|
//qDebug("%s", qPrintable(QString(buf.toHex())));
|
||||||
|
|
||||||
// TODO: emit status("Writing to disk...");
|
// TODO: emit status("Writing to disk...");
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||||
@ -402,7 +393,7 @@ _content_not_init:
|
|||||||
.arg(QString().fromStdString(content.DebugString()));
|
.arg(QString().fromStdString(content.DebugString()));
|
||||||
goto _fail;
|
goto _fail;
|
||||||
_fail:
|
_fail:
|
||||||
qDebug("%s", error.toAscii().constData());
|
qDebug("%s", qPrintable(error));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,7 +422,7 @@ bool NativeFileFormat::isNativeFileFormat(
|
|||||||
if (!meta.ParseFromArray(
|
if (!meta.ParseFromArray(
|
||||||
(void*)(buf.constData() + kFileMetaDataOffset), metaSize)) {
|
(void*)(buf.constData() + kFileMetaDataOffset), metaSize)) {
|
||||||
qDebug("%s: File MetaData\n%s", __FUNCTION__,
|
qDebug("%s: File MetaData\n%s", __FUNCTION__,
|
||||||
QString().fromStdString(meta.DebugString()).toAscii().constData());
|
meta.DebugString().c_str());
|
||||||
goto _close_exit;
|
goto _close_exit;
|
||||||
}
|
}
|
||||||
if (meta.data().file_type() == fileType)
|
if (meta.data().file_type() == fileType)
|
||||||
|
@ -50,7 +50,7 @@ _missing_session:
|
|||||||
error = QString(tr("%1 does not contain a session")).arg(fileName);
|
error = QString(tr("%1 does not contain a session")).arg(fileName);
|
||||||
goto _fail;
|
goto _fail;
|
||||||
_fail:
|
_fail:
|
||||||
qDebug("%s", error.toAscii().constData());
|
qDebug("%s", qPrintable(error));
|
||||||
_exit:
|
_exit:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ _session_not_init:
|
|||||||
.arg(QString().fromStdString(session.DebugString()));
|
.arg(QString().fromStdString(session.DebugString()));
|
||||||
goto _fail;
|
goto _fail;
|
||||||
_fail:
|
_fail:
|
||||||
qDebug("%s", error.toAscii().constData());
|
qDebug("%s", qPrintable(error));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ _missing_streams:
|
|||||||
error = QString(tr("%1 does not contain any streams")).arg(fileName);
|
error = QString(tr("%1 does not contain any streams")).arg(fileName);
|
||||||
goto _fail;
|
goto _fail;
|
||||||
_fail:
|
_fail:
|
||||||
qDebug("%s", error.toAscii().constData());
|
qDebug("%s", qPrintable(error));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ _stream_not_init:
|
|||||||
.arg(QString().fromStdString(streams.DebugString()));
|
.arg(QString().fromStdString(streams.DebugString()));
|
||||||
goto _fail;
|
goto _fail;
|
||||||
_fail:
|
_fail:
|
||||||
qDebug("%s", error.toAscii().constData());
|
qDebug("%s", qPrintable(error));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
CONFIG += qt staticlib
|
CONFIG += qt staticlib
|
||||||
QT += network xml script
|
QT += widgets network xml script
|
||||||
INCLUDEPATH += "../extra/qhexedit2/src"
|
INCLUDEPATH += "../extra/qhexedit2/src"
|
||||||
LIBS += \
|
LIBS += \
|
||||||
-lprotobuf
|
-lprotobuf
|
||||||
|
@ -115,7 +115,7 @@ bool PcapFileFormat::open(const QString fileName,
|
|||||||
goto _err_unzip_fail;
|
goto _err_unzip_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("decompressing to %s", file2.fileName().toAscii().constData());
|
qDebug("decompressing to %s", qPrintable(file2.fileName()));
|
||||||
|
|
||||||
gzip.setStandardOutputFile(file2.fileName());
|
gzip.setStandardOutputFile(file2.fileName());
|
||||||
gzip.start(OstProtoLib::gzipPath(),
|
gzip.start(OstProtoLib::gzipPath(),
|
||||||
@ -195,7 +195,7 @@ bool PcapFileFormat::open(const QString fileName,
|
|||||||
goto _non_pdml;
|
goto _non_pdml;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("generating PDML %s", pdmlFile.fileName().toAscii().constData());
|
qDebug("generating PDML %s", qPrintable(pdmlFile.fileName()));
|
||||||
emit status("Generating PDML...");
|
emit status("Generating PDML...");
|
||||||
emit target(0);
|
emit target(0);
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ bool PcapFileFormat::open(const QString fileName,
|
|||||||
goto _diff_fail;
|
goto _diff_fail;
|
||||||
}
|
}
|
||||||
qDebug("generating text file (original) %s",
|
qDebug("generating text file (original) %s",
|
||||||
originalTextFile.fileName().toAscii().constData());
|
qPrintable(originalTextFile.fileName()));
|
||||||
|
|
||||||
emit status("Preparing original PCAP for diff...");
|
emit status("Preparing original PCAP for diff...");
|
||||||
emit target(0);
|
emit target(0);
|
||||||
@ -325,7 +325,7 @@ bool PcapFileFormat::open(const QString fileName,
|
|||||||
goto _diff_fail;
|
goto _diff_fail;
|
||||||
}
|
}
|
||||||
qDebug("generating text file (imported) %s",
|
qDebug("generating text file (imported) %s",
|
||||||
importedTextFile.fileName().toAscii().constData());
|
qPrintable(importedTextFile.fileName()));
|
||||||
|
|
||||||
emit status("Preparing imported PCAP for diff...");
|
emit status("Preparing imported PCAP for diff...");
|
||||||
emit target(0);
|
emit target(0);
|
||||||
@ -370,9 +370,9 @@ bool PcapFileFormat::open(const QString fileName,
|
|||||||
goto _diff_fail;
|
goto _diff_fail;
|
||||||
}
|
}
|
||||||
qDebug("diffing %s and %s > %s",
|
qDebug("diffing %s and %s > %s",
|
||||||
originalTextFile.fileName().toAscii().constData(),
|
qPrintable(originalTextFile.fileName()),
|
||||||
importedTextFile.fileName().toAscii().constData(),
|
qPrintable(importedTextFile.fileName()),
|
||||||
diffFile.fileName().toAscii().constData());
|
qPrintable(diffFile.fileName()));
|
||||||
|
|
||||||
emit status("Taking diff...");
|
emit status("Taking diff...");
|
||||||
emit target(0);
|
emit target(0);
|
||||||
|
@ -91,7 +91,7 @@ bool PdmlFileFormat::save(const OstProto::StreamConfigList streams,
|
|||||||
goto _fail;
|
goto _fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("intermediate PCAP %s", pcapFile.fileName().toAscii().constData());
|
qDebug("intermediate PCAP %s", qPrintable(pcapFile.fileName()));
|
||||||
|
|
||||||
connect(fmt, SIGNAL(target(int)), this, SIGNAL(target(int)));
|
connect(fmt, SIGNAL(target(int)), this, SIGNAL(target(int)));
|
||||||
connect(fmt, SIGNAL(progress(int)), this, SIGNAL(progress(int)));
|
connect(fmt, SIGNAL(progress(int)), this, SIGNAL(progress(int)));
|
||||||
@ -99,7 +99,7 @@ bool PdmlFileFormat::save(const OstProto::StreamConfigList streams,
|
|||||||
emit status("Writing intermediate PCAP file...");
|
emit status("Writing intermediate PCAP file...");
|
||||||
isOk = fmt->save(streams, pcapFile.fileName(), error);
|
isOk = fmt->save(streams, pcapFile.fileName(), error);
|
||||||
|
|
||||||
qDebug("generating PDML %s", fileName.toAscii().constData());
|
qDebug("generating PDML %s", qPrintable(fileName));
|
||||||
emit status("Converting PCAP to PDML...");
|
emit status("Converting PCAP to PDML...");
|
||||||
emit target(0);
|
emit target(0);
|
||||||
|
|
||||||
|
@ -162,8 +162,8 @@ void PdmlProtocol::fieldHandler(QString name,
|
|||||||
QString valueHexStr = attributes.value("value").toString();
|
QString valueHexStr = attributes.value("value").toString();
|
||||||
|
|
||||||
qDebug("\t(KNOWN) fieldName:%s, value:%s",
|
qDebug("\t(KNOWN) fieldName:%s, value:%s",
|
||||||
name.toAscii().constData(),
|
qPrintable(name),
|
||||||
valueHexStr.toAscii().constData());
|
qPrintable(valueHexStr));
|
||||||
|
|
||||||
knownFieldHandler(name, valueHexStr, pbProto);
|
knownFieldHandler(name, valueHexStr, pbProto);
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ void PdmlProtocol::fieldHandler(QString name,
|
|||||||
size = attributes.value("size").toString().toInt();
|
size = attributes.value("size").toString().toInt();
|
||||||
|
|
||||||
qDebug("\t(UNKNOWN) fieldName:%s, pos:%d, size:%d",
|
qDebug("\t(UNKNOWN) fieldName:%s, pos:%d, size:%d",
|
||||||
name.toAscii().constData(), pos, size);
|
qPrintable(name), pos, size);
|
||||||
|
|
||||||
unknownFieldHandler(name, pos, size, attributes, pbProto, stream);
|
unknownFieldHandler(name, pos, size, attributes, pbProto, stream);
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ void PdmlUnknownProtocol::unknownFieldHandler(QString name, int pos,
|
|||||||
OstProto::HexDump *hexDump = pbProto->MutableExtension(OstProto::hexDump);
|
OstProto::HexDump *hexDump = pbProto->MutableExtension(OstProto::hexDump);
|
||||||
|
|
||||||
qDebug(" hexdump: %s, pos = %d, expPos_ = %d, endPos_ = %d\n",
|
qDebug(" hexdump: %s, pos = %d, expPos_ = %d, endPos_ = %d\n",
|
||||||
name.toAscii().constData(),
|
qPrintable(name),
|
||||||
pos, expPos_, endPos_);
|
pos, expPos_, endPos_);
|
||||||
|
|
||||||
// Skipped field? Pad with zero!
|
// Skipped field? Pad with zero!
|
||||||
|
@ -107,7 +107,7 @@ bool PdmlReader::read(QIODevice *device, PcapFileFormat *pcap, bool *stop)
|
|||||||
{
|
{
|
||||||
qDebug("Line %lld", lineNumber());
|
qDebug("Line %lld", lineNumber());
|
||||||
qDebug("Col %lld", columnNumber());
|
qDebug("Col %lld", columnNumber());
|
||||||
qDebug("%s", errorString().toAscii().constData());
|
qDebug("%s", qPrintable(errorString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -151,8 +151,7 @@ void PdmlReader::skipElement()
|
|||||||
{
|
{
|
||||||
Q_ASSERT(isStartElement());
|
Q_ASSERT(isStartElement());
|
||||||
|
|
||||||
qDebug("skipping element - <%s>",
|
qDebug("skipping element - <%s>", qPrintable(name().toString()));
|
||||||
name().toString().toAscii().constData());
|
|
||||||
while (!atEnd())
|
while (!atEnd())
|
||||||
{
|
{
|
||||||
readNext();
|
readNext();
|
||||||
@ -298,7 +297,7 @@ void PdmlReader::readProto()
|
|||||||
size = attributes().value("size").toString().toInt();
|
size = attributes().value("size").toString().toInt();
|
||||||
|
|
||||||
qDebug("proto: %s, pos = %d, expPos_ = %d, size = %d",
|
qDebug("proto: %s, pos = %d, expPos_ = %d, size = %d",
|
||||||
protoName.toAscii().constData(), pos, expPos_, size);
|
qPrintable(protoName), pos, expPos_, size);
|
||||||
|
|
||||||
// This is a heuristic to skip protocols which are not part of
|
// This is a heuristic to skip protocols which are not part of
|
||||||
// this frame, but of a reassembled segment spanning several frames
|
// this frame, but of a reassembled segment spanning several frames
|
||||||
@ -355,7 +354,7 @@ void PdmlReader::readProto()
|
|||||||
pdmlProto = appendPdmlProto(protoName, &pbProto);
|
pdmlProto = appendPdmlProto(protoName, &pbProto);
|
||||||
|
|
||||||
qDebug("%s: preProtocolHandler(expPos = %d)",
|
qDebug("%s: preProtocolHandler(expPos = %d)",
|
||||||
protoName.toAscii().constData(), expPos_);
|
qPrintable(protoName), expPos_);
|
||||||
pdmlProto->preProtocolHandler(protoName, attributes(), expPos_, pbProto,
|
pdmlProto->preProtocolHandler(protoName, attributes(), expPos_, pbProto,
|
||||||
currentStream_);
|
currentStream_);
|
||||||
|
|
||||||
@ -371,8 +370,8 @@ void PdmlReader::readProto()
|
|||||||
if (name() == "proto")
|
if (name() == "proto")
|
||||||
{
|
{
|
||||||
// an embedded proto
|
// an embedded proto
|
||||||
qDebug("embedded proto: %s\n", attributes().value("name")
|
qDebug("embedded proto: %s\n",
|
||||||
.toString().toAscii().constData());
|
qPrintable(attributes().value("name").toString()));
|
||||||
|
|
||||||
if (isDontCareProto())
|
if (isDontCareProto())
|
||||||
{
|
{
|
||||||
@ -423,7 +422,7 @@ void PdmlReader::readProto()
|
|||||||
pdmlProto = appendPdmlProto(protoName, &pbProto);
|
pdmlProto = appendPdmlProto(protoName, &pbProto);
|
||||||
|
|
||||||
qDebug("%s: preProtocolHandler(expPos = %d)",
|
qDebug("%s: preProtocolHandler(expPos = %d)",
|
||||||
protoName.toAscii().constData(), expPos_);
|
qPrintable(protoName), expPos_);
|
||||||
pdmlProto->preProtocolHandler(protoName, attributes(),
|
pdmlProto->preProtocolHandler(protoName, attributes(),
|
||||||
expPos_, pbProto, currentStream_);
|
expPos_, pbProto, currentStream_);
|
||||||
}
|
}
|
||||||
@ -461,7 +460,7 @@ void PdmlReader::readField(PdmlProtocol *pdmlProto,
|
|||||||
|
|
||||||
QString fieldName = attributes().value("name").toString();
|
QString fieldName = attributes().value("name").toString();
|
||||||
|
|
||||||
qDebug(" fieldName:%s", fieldName.toAscii().constData());
|
qDebug(" fieldName:%s", qPrintable(fieldName));
|
||||||
|
|
||||||
pdmlProto->fieldHandler(fieldName, attributes(), pbProto, currentStream_);
|
pdmlProto->fieldHandler(fieldName, attributes(), pbProto, currentStream_);
|
||||||
|
|
||||||
@ -540,8 +539,7 @@ PdmlProtocol* PdmlReader::appendPdmlProto(const QString &protoName,
|
|||||||
|
|
||||||
*pbProto = proto;
|
*pbProto = proto;
|
||||||
|
|
||||||
qDebug("%s: name = %s", __FUNCTION__,
|
qDebug("%s: name = %s", __FUNCTION__, qPrintable(protoName));
|
||||||
protoName.toAscii().constData());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*pbProto = NULL;
|
*pbProto = NULL;
|
||||||
|
@ -157,12 +157,12 @@ inline UInt128 UInt128::operator|(const UInt128 &other) const
|
|||||||
return UInt128(hi_ | other.hi_, lo_ | other.lo_);
|
return UInt128(hi_ | other.hi_, lo_ | other.lo_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> inline UInt128 qFromBigEndian<UInt128>(const uchar *src)
|
template <> inline UInt128 qFromBigEndian<UInt128>(const void *src)
|
||||||
{
|
{
|
||||||
quint64 hi, lo;
|
quint64 hi, lo;
|
||||||
|
|
||||||
hi = qFromBigEndian<quint64>(src);
|
hi = qFromBigEndian<quint64>(src);
|
||||||
lo = qFromBigEndian<quint64>(src+8);
|
lo = qFromBigEndian<quint64>((uchar*)src+8);
|
||||||
|
|
||||||
return UInt128(hi, lo);
|
return UInt128(hi, lo);
|
||||||
}
|
}
|
||||||
|
@ -20,16 +20,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "updater.h"
|
#include "updater.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QHttp>
|
#include <QNetworkAccessManager>
|
||||||
#include <QTemporaryFile>
|
#include <QNetworkReply>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
|
|
||||||
extern const char* version;
|
extern const char* version;
|
||||||
|
|
||||||
Updater::Updater()
|
Updater::Updater()
|
||||||
{
|
{
|
||||||
http_ = NULL;
|
http_ = new QNetworkAccessManager(this);
|
||||||
file_ = NULL;
|
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
// Tests!
|
// Tests!
|
||||||
@ -44,60 +43,39 @@ Updater::Updater()
|
|||||||
Updater::~Updater()
|
Updater::~Updater()
|
||||||
{
|
{
|
||||||
delete http_;
|
delete http_;
|
||||||
delete file_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Updater::checkForNewVersion()
|
void Updater::checkForNewVersion()
|
||||||
{
|
{
|
||||||
QString host("update.ostinato.org");
|
QNetworkRequest request(QUrl("http://update.ostinato.org/update/pad.xml"));
|
||||||
QHttpRequestHeader reqHdr("GET", "/update/pad.xml");
|
|
||||||
http_ = new QHttp(host);
|
|
||||||
file_ = new QTemporaryFile();
|
|
||||||
|
|
||||||
reqHdr.setValue("Host", host);
|
//reqHdr.setHeader("Host", host);
|
||||||
reqHdr.setValue("User-Agent", userAgent());
|
request.setHeader(QNetworkRequest::UserAgentHeader, userAgent());
|
||||||
|
|
||||||
connect(http_, SIGNAL(responseHeaderReceived(QHttpResponseHeader)),
|
connect(http_, SIGNAL(finished(QNetworkReply*)),
|
||||||
this, SLOT(responseReceived(QHttpResponseHeader)));
|
this, SLOT(parseXml(QNetworkReply*)));
|
||||||
connect(http_, SIGNAL(requestFinished(int, bool)),
|
|
||||||
this, SLOT(parseXml(int, bool)));
|
|
||||||
connect(http_, SIGNAL(stateChanged(int)),
|
|
||||||
this, SLOT(stateUpdate(int)));
|
|
||||||
|
|
||||||
file_->open();
|
http_->get(request);
|
||||||
qDebug("Updater: PAD XML file - %s", qPrintable(file_->fileName()));
|
|
||||||
|
|
||||||
http_->request(reqHdr, NULL, file_);
|
QList<QByteArray> headers = request.rawHeaderList();
|
||||||
qDebug("Updater: %s", qPrintable(http_->currentRequest().toString()
|
foreach(QByteArray hdr, headers ) {
|
||||||
.replace("\r\n", "\nUpdater: ")));
|
QByteArray val = request.rawHeader(hdr);
|
||||||
|
qDebug("Updater: %s: %s", qPrintable(QString(hdr)),
|
||||||
|
qPrintable(QString(val)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Updater::stateUpdate(int state)
|
void Updater::parseXml(QNetworkReply *reply)
|
||||||
{
|
|
||||||
qDebug("Updater: state %d", state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Updater::responseReceived(QHttpResponseHeader response)
|
|
||||||
{
|
|
||||||
qDebug("Updater: HTTP/%d.%d %d %s",
|
|
||||||
response.majorVersion(), response.minorVersion(),
|
|
||||||
response.statusCode(), qPrintable(response.reasonPhrase()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Updater::parseXml(int /*id*/, bool error)
|
|
||||||
{
|
{
|
||||||
QXmlStreamReader xml;
|
QXmlStreamReader xml;
|
||||||
QString newVersion;
|
QString newVersion;
|
||||||
|
|
||||||
if (error) {
|
if (reply->error()) {
|
||||||
qDebug("Updater: %s", qPrintable(http_->errorString()));
|
qDebug("Updater: %s", qPrintable(reply->errorString()));
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close and reopen the file so that we read from the top
|
xml.setDevice(reply);
|
||||||
file_->close();
|
|
||||||
file_->open();
|
|
||||||
xml.setDevice(file_);
|
|
||||||
|
|
||||||
while (!xml.atEnd()) {
|
while (!xml.atEnd()) {
|
||||||
xml.readNext();
|
xml.readNext();
|
||||||
|
@ -20,11 +20,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#ifndef _UPDATER_H
|
#ifndef _UPDATER_H
|
||||||
#define _UPDATER_H
|
#define _UPDATER_H
|
||||||
|
|
||||||
#include <QHttpResponseHeader>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class QHttp;
|
class QNetworkAccessManager;
|
||||||
class QTemporaryFile;
|
class QNetworkReply;
|
||||||
|
|
||||||
class Updater : public QObject
|
class Updater : public QObject
|
||||||
{
|
{
|
||||||
@ -39,16 +39,13 @@ signals:
|
|||||||
void newVersionAvailable(QString);
|
void newVersionAvailable(QString);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void stateUpdate(int state);
|
void parseXml(QNetworkReply *reply);
|
||||||
void responseReceived(QHttpResponseHeader response);
|
|
||||||
void parseXml(int id, bool error);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString userAgent();
|
QString userAgent();
|
||||||
QString sysInfo();
|
QString sysInfo();
|
||||||
|
|
||||||
QHttp *http_;
|
QNetworkAccessManager *http_;
|
||||||
QTemporaryFile *file_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -281,7 +281,7 @@ void UserScriptProtocol::evaluateUserScript() const
|
|||||||
userFunction = userProtocolScriptValue_.property(property);
|
userFunction = userProtocolScriptValue_.property(property);
|
||||||
|
|
||||||
qDebug("userscript property %s: isValid:%d/isFunc:%d",
|
qDebug("userscript property %s: isValid:%d/isFunc:%d",
|
||||||
property.toAscii().constData(),
|
qPrintable(property),
|
||||||
userFunction.isValid(), userFunction.isFunction());
|
userFunction.isValid(), userFunction.isFunction());
|
||||||
|
|
||||||
if (!userFunction.isValid())
|
if (!userFunction.isValid())
|
||||||
@ -301,7 +301,7 @@ void UserScriptProtocol::evaluateUserScript() const
|
|||||||
goto _error_exception;
|
goto _error_exception;
|
||||||
|
|
||||||
qDebug("userscript property %s return value: isValid:%d/isArray:%d",
|
qDebug("userscript property %s return value: isValid:%d/isArray:%d",
|
||||||
property.toAscii().constData(),
|
qPrintable(property),
|
||||||
userValue.isValid(), userValue.isArray());
|
userValue.isValid(), userValue.isArray());
|
||||||
|
|
||||||
if (!userValue.isArray())
|
if (!userValue.isArray())
|
||||||
@ -315,7 +315,7 @@ void UserScriptProtocol::evaluateUserScript() const
|
|||||||
userFunction = userProtocolScriptValue_.property(property);
|
userFunction = userProtocolScriptValue_.property(property);
|
||||||
|
|
||||||
qDebug("userscript property %s: isValid:%d/isFunc:%d",
|
qDebug("userscript property %s: isValid:%d/isFunc:%d",
|
||||||
property.toAscii().constData(),
|
qPrintable(property),
|
||||||
userFunction.isValid(), userFunction.isFunction());
|
userFunction.isValid(), userFunction.isFunction());
|
||||||
|
|
||||||
if (!userFunction.isValid())
|
if (!userFunction.isValid())
|
||||||
@ -335,7 +335,7 @@ void UserScriptProtocol::evaluateUserScript() const
|
|||||||
goto _error_exception;
|
goto _error_exception;
|
||||||
|
|
||||||
qDebug("userscript property %s return value: isValid:%d/isNumber:%d",
|
qDebug("userscript property %s return value: isValid:%d/isNumber:%d",
|
||||||
property.toAscii().constData(),
|
qPrintable(property),
|
||||||
userValue.isValid(), userValue.isNumber());
|
userValue.isValid(), userValue.isNumber());
|
||||||
|
|
||||||
if (!userValue.isNumber())
|
if (!userValue.isNumber())
|
||||||
@ -349,7 +349,7 @@ void UserScriptProtocol::evaluateUserScript() const
|
|||||||
userFunction = userProtocolScriptValue_.property(property);
|
userFunction = userProtocolScriptValue_.property(property);
|
||||||
|
|
||||||
qDebug("userscript property %s: isValid:%d/isFunc:%d",
|
qDebug("userscript property %s: isValid:%d/isFunc:%d",
|
||||||
property.toAscii().constData(),
|
qPrintable(property),
|
||||||
userFunction.isValid(), userFunction.isFunction());
|
userFunction.isValid(), userFunction.isFunction());
|
||||||
|
|
||||||
if (!userFunction.isValid())
|
if (!userFunction.isValid())
|
||||||
@ -366,7 +366,7 @@ void UserScriptProtocol::evaluateUserScript() const
|
|||||||
goto _error_exception;
|
goto _error_exception;
|
||||||
|
|
||||||
qDebug("userscript property %s return value: isValid:%d/isNumber:%d",
|
qDebug("userscript property %s return value: isValid:%d/isNumber:%d",
|
||||||
property.toAscii().constData(),
|
qPrintable(property),
|
||||||
userValue.isValid(), userValue.isNumber());
|
userValue.isValid(), userValue.isNumber());
|
||||||
|
|
||||||
if (!userValue.isNumber())
|
if (!userValue.isNumber())
|
||||||
@ -382,7 +382,7 @@ _skip_cksum:
|
|||||||
userFunction = userProtocolScriptValue_.property(property);
|
userFunction = userProtocolScriptValue_.property(property);
|
||||||
|
|
||||||
qDebug("userscript property %s: isValid:%d/isFunc:%d",
|
qDebug("userscript property %s: isValid:%d/isFunc:%d",
|
||||||
property.toAscii().constData(),
|
qPrintable(property),
|
||||||
userFunction.isValid(), userFunction.isFunction());
|
userFunction.isValid(), userFunction.isFunction());
|
||||||
|
|
||||||
if (!userFunction.isValid())
|
if (!userFunction.isValid())
|
||||||
@ -399,7 +399,7 @@ _skip_cksum:
|
|||||||
goto _error_exception;
|
goto _error_exception;
|
||||||
|
|
||||||
qDebug("userscript property %s return value: isValid:%d/isNumber:%d",
|
qDebug("userscript property %s return value: isValid:%d/isNumber:%d",
|
||||||
property.toAscii().constData(),
|
qPrintable(property),
|
||||||
userValue.isValid(), userValue.isNumber());
|
userValue.isValid(), userValue.isNumber());
|
||||||
|
|
||||||
if (!userValue.isNumber())
|
if (!userValue.isNumber())
|
||||||
|
@ -21,8 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#define _PB_RPC_COMMON_H
|
#define _PB_RPC_COMMON_H
|
||||||
|
|
||||||
// Print a HexDump
|
// Print a HexDump
|
||||||
#define BUFDUMP(ptr, len) qDebug("%s", QString(QByteArray((char*)(ptr), \
|
#define BUFDUMP(ptr, len) qDebug("%s", \
|
||||||
(len)).toHex()).toAscii().data());
|
qPrintable(QString(QByteArray((char*)(ptr), (len)).toHex())));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** RPC Header (8)
|
** RPC Header (8)
|
||||||
|
@ -59,7 +59,7 @@ RpcConnection::RpcConnection(int socketDescriptor,
|
|||||||
RpcConnection::~RpcConnection()
|
RpcConnection::~RpcConnection()
|
||||||
{
|
{
|
||||||
qDebug("destroying connection to %s: %d",
|
qDebug("destroying connection to %s: %d",
|
||||||
clientSock->peerAddress().toString().toAscii().constData(),
|
qPrintable(clientSock->peerAddress().toString()),
|
||||||
clientSock->peerPort());
|
clientSock->peerPort());
|
||||||
|
|
||||||
// If still connected, disconnect
|
// If still connected, disconnect
|
||||||
@ -89,7 +89,7 @@ void RpcConnection::start()
|
|||||||
.arg(clientSock->peerPort())));
|
.arg(clientSock->peerPort())));
|
||||||
|
|
||||||
qDebug("accepting new connection from %s: %d",
|
qDebug("accepting new connection from %s: %d",
|
||||||
clientSock->peerAddress().toString().toAscii().constData(),
|
qPrintable(clientSock->peerAddress().toString()),
|
||||||
clientSock->peerPort());
|
clientSock->peerPort());
|
||||||
inStream = new google::protobuf::io::CopyingInputStreamAdaptor(
|
inStream = new google::protobuf::io::CopyingInputStreamAdaptor(
|
||||||
new PbQtInputStream(clientSock));
|
new PbQtInputStream(clientSock));
|
||||||
@ -240,7 +240,7 @@ void RpcConnection::sendNotification(int notifType,
|
|||||||
void RpcConnection::on_clientSock_disconnected()
|
void RpcConnection::on_clientSock_disconnected()
|
||||||
{
|
{
|
||||||
qDebug("connection closed from %s: %d",
|
qDebug("connection closed from %s: %d",
|
||||||
clientSock->peerAddress().toString().toAscii().constData(),
|
qPrintable(clientSock->peerAddress().toString()),
|
||||||
clientSock->peerPort());
|
clientSock->peerPort());
|
||||||
|
|
||||||
deleteLater();
|
deleteLater();
|
||||||
@ -249,8 +249,7 @@ void RpcConnection::on_clientSock_disconnected()
|
|||||||
|
|
||||||
void RpcConnection::on_clientSock_error(QAbstractSocket::SocketError socketError)
|
void RpcConnection::on_clientSock_error(QAbstractSocket::SocketError socketError)
|
||||||
{
|
{
|
||||||
qDebug("%s (%d)", clientSock->errorString().toAscii().constData(),
|
qDebug("%s (%d)", qPrintable(clientSock->errorString()), socketError);
|
||||||
socketError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RpcConnection::on_clientSock_dataAvail()
|
void RpcConnection::on_clientSock_dataAvail()
|
||||||
@ -399,7 +398,8 @@ _error_exit2:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RpcConnection::connIdMsgHandler(QtMsgType /*type*/, const char* msg)
|
void RpcConnection::connIdMsgHandler(QtMsgType /*type*/,
|
||||||
|
const QMessageLogContext &/*context*/, const QString &msg)
|
||||||
{
|
{
|
||||||
if (connId.hasLocalData()) {
|
if (connId.hasLocalData()) {
|
||||||
QString newMsg(*connId.localData());
|
QString newMsg(*connId.localData());
|
||||||
@ -410,6 +410,6 @@ void RpcConnection::connIdMsgHandler(QtMsgType /*type*/, const char* msg)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "%s\n", msg);
|
fprintf(stderr, "%s\n", qPrintable(msg));
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,9 @@ public:
|
|||||||
RpcConnection(int socketDescriptor, ::google::protobuf::Service *service);
|
RpcConnection(int socketDescriptor, ::google::protobuf::Service *service);
|
||||||
virtual ~RpcConnection();
|
virtual ~RpcConnection();
|
||||||
|
|
||||||
static void connIdMsgHandler(QtMsgType type, const char* msg);
|
static void connIdMsgHandler(QtMsgType type,
|
||||||
|
const QMessageLogContext &context,
|
||||||
|
const QString &msg);
|
||||||
private:
|
private:
|
||||||
void writeHeader(char* header, quint16 type, quint16 method,
|
void writeHeader(char* header, quint16 type, quint16 method,
|
||||||
quint32 length);
|
quint32 length);
|
||||||
|
@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include "rpcconn.h"
|
#include "rpcconn.h"
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
// FIXME: QThreadX till we change minimum version of Qt from Qt4.3+ to Qt4.4+
|
// FIXME: QThreadX till we change minimum version of Qt from Qt4.3+ to Qt4.4+
|
||||||
@ -35,7 +36,7 @@ RpcServer::RpcServer()
|
|||||||
{
|
{
|
||||||
service = NULL;
|
service = NULL;
|
||||||
|
|
||||||
qInstallMsgHandler(RpcConnection::connIdMsgHandler);
|
qInstallMessageHandler(RpcConnection::connIdMsgHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
RpcServer::~RpcServer()
|
RpcServer::~RpcServer()
|
||||||
@ -51,12 +52,12 @@ bool RpcServer::registerService(::google::protobuf::Service *service,
|
|||||||
{
|
{
|
||||||
qDebug("Unable to start the server on <%s>: %s",
|
qDebug("Unable to start the server on <%s>: %s",
|
||||||
qPrintable(address.toString()),
|
qPrintable(address.toString()),
|
||||||
errorString().toAscii().constData());
|
qPrintable(errorString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("The server is running on %s: %d",
|
qDebug("The server is running on %s: %d",
|
||||||
serverAddress().toString().toAscii().constData(),
|
qPrintable(serverAddress().toString()),
|
||||||
serverPort());
|
serverPort());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user