Refactored StreamFileFormat and subclasses' methods to be consistent with SessionFileFormat
This commit is contained in:
parent
ff066ea657
commit
6cc7231e7f
@ -583,12 +583,12 @@ bool Port::openStreams(QString fileName, bool append, QString &error)
|
|||||||
connect(fmt, SIGNAL(progress(int)), &progress, SLOT(setValue(int)));
|
connect(fmt, SIGNAL(progress(int)), &progress, SLOT(setValue(int)));
|
||||||
connect(&progress, SIGNAL(canceled()), fmt, SLOT(cancel()));
|
connect(&progress, SIGNAL(canceled()), fmt, SLOT(cancel()));
|
||||||
|
|
||||||
fmt->openStreamsOffline(fileName, streams, error);
|
fmt->openAsync(fileName, streams, error);
|
||||||
qDebug("after open offline");
|
qDebug("after open async");
|
||||||
|
|
||||||
while (!fmt->isFinished())
|
while (!fmt->isFinished())
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
qDebug("wait over for offline operation");
|
qDebug("wait over for async operation");
|
||||||
|
|
||||||
if (!fmt->result())
|
if (!fmt->result())
|
||||||
goto _fail;
|
goto _fail;
|
||||||
@ -676,12 +676,12 @@ bool Port::saveStreams(QString fileName, QString fileType, QString &error)
|
|||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt->saveStreamsOffline(streams, fileName, error);
|
fmt->saveAsync(streams, fileName, error);
|
||||||
qDebug("after save offline");
|
qDebug("after save async");
|
||||||
|
|
||||||
while (!fmt->isFinished())
|
while (!fmt->isFinished())
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
qDebug("wait over for offline operation");
|
qDebug("wait over for async operation");
|
||||||
|
|
||||||
ret = fmt->result();
|
ret = fmt->result();
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
@ -27,7 +27,7 @@ OstmFileFormat::OstmFileFormat()
|
|||||||
// Do Nothing!
|
// Do Nothing!
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OstmFileFormat::openStreams(const QString fileName,
|
bool OstmFileFormat::open(const QString fileName,
|
||||||
OstProto::StreamConfigList &streams, QString &error)
|
OstProto::StreamConfigList &streams, QString &error)
|
||||||
{
|
{
|
||||||
OstProto::FileMeta meta;
|
OstProto::FileMeta meta;
|
||||||
@ -54,7 +54,7 @@ _fail:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OstmFileFormat::saveStreams(const OstProto::StreamConfigList streams,
|
bool OstmFileFormat::save(const OstProto::StreamConfigList streams,
|
||||||
const QString fileName, QString &error)
|
const QString fileName, QString &error)
|
||||||
{
|
{
|
||||||
OstProto::FileContent content;
|
OstProto::FileContent content;
|
||||||
|
@ -29,9 +29,9 @@ class OstmFileFormat : public StreamFileFormat, public NativeFileFormat
|
|||||||
public:
|
public:
|
||||||
OstmFileFormat();
|
OstmFileFormat();
|
||||||
|
|
||||||
virtual bool openStreams(const QString fileName,
|
virtual bool open(const QString fileName,
|
||||||
OstProto::StreamConfigList &streams, QString &error);
|
OstProto::StreamConfigList &streams, QString &error);
|
||||||
virtual bool saveStreams(const OstProto::StreamConfigList streams,
|
virtual bool save(const OstProto::StreamConfigList streams,
|
||||||
const QString fileName, QString &error);
|
const QString fileName, QString &error);
|
||||||
|
|
||||||
bool isMyFileFormat(const QString fileName);
|
bool isMyFileFormat(const QString fileName);
|
||||||
|
@ -91,7 +91,7 @@ PcapFileFormat::~PcapFileFormat()
|
|||||||
delete importDialog_;
|
delete importDialog_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PcapFileFormat::openStreams(const QString fileName,
|
bool PcapFileFormat::open(const QString fileName,
|
||||||
OstProto::StreamConfigList &streams, QString &error)
|
OstProto::StreamConfigList &streams, QString &error)
|
||||||
{
|
{
|
||||||
bool isOk = false;
|
bool isOk = false;
|
||||||
@ -325,7 +325,7 @@ bool PcapFileFormat::openStreams(const QString fileName,
|
|||||||
goto _diff_fail;
|
goto _diff_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!saveStreams(streams, importedPcapFile.fileName(), error))
|
if (!save(streams, importedPcapFile.fileName(), error))
|
||||||
{
|
{
|
||||||
error.append("Error saving imported streams as PCAP for diff");
|
error.append("Error saving imported streams as PCAP for diff");
|
||||||
goto _diff_fail;
|
goto _diff_fail;
|
||||||
@ -553,7 +553,7 @@ bool PcapFileFormat::readPacket(PcapPacketHeader &pktHdr, QByteArray &pktBuf)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PcapFileFormat::saveStreams(const OstProto::StreamConfigList streams,
|
bool PcapFileFormat::save(const OstProto::StreamConfigList streams,
|
||||||
const QString fileName, QString &error)
|
const QString fileName, QString &error)
|
||||||
{
|
{
|
||||||
bool isOk = false;
|
bool isOk = false;
|
||||||
|
@ -47,9 +47,9 @@ public:
|
|||||||
PcapFileFormat();
|
PcapFileFormat();
|
||||||
~PcapFileFormat();
|
~PcapFileFormat();
|
||||||
|
|
||||||
bool openStreams(const QString fileName,
|
bool open(const QString fileName,
|
||||||
OstProto::StreamConfigList &streams, QString &error);
|
OstProto::StreamConfigList &streams, QString &error);
|
||||||
bool saveStreams(const OstProto::StreamConfigList streams,
|
bool save(const OstProto::StreamConfigList streams,
|
||||||
const QString fileName, QString &error);
|
const QString fileName, QString &error);
|
||||||
|
|
||||||
virtual QDialog* openOptionsDialog();
|
virtual QDialog* openOptionsDialog();
|
||||||
|
@ -35,7 +35,7 @@ PdmlFileFormat::~PdmlFileFormat()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PdmlFileFormat::openStreams(const QString fileName,
|
bool PdmlFileFormat::open(const QString fileName,
|
||||||
OstProto::StreamConfigList &streams, QString &error)
|
OstProto::StreamConfigList &streams, QString &error)
|
||||||
{
|
{
|
||||||
bool isOk = false;
|
bool isOk = false;
|
||||||
@ -75,7 +75,7 @@ _exit:
|
|||||||
return isOk;
|
return isOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PdmlFileFormat::saveStreams(const OstProto::StreamConfigList streams,
|
bool PdmlFileFormat::save(const OstProto::StreamConfigList streams,
|
||||||
const QString fileName, QString &error)
|
const QString fileName, QString &error)
|
||||||
{
|
{
|
||||||
bool isOk = false;
|
bool isOk = false;
|
||||||
@ -97,7 +97,7 @@ bool PdmlFileFormat::saveStreams(const OstProto::StreamConfigList streams,
|
|||||||
connect(fmt, SIGNAL(progress(int)), this, SIGNAL(progress(int)));
|
connect(fmt, SIGNAL(progress(int)), this, SIGNAL(progress(int)));
|
||||||
|
|
||||||
emit status("Writing intermediate PCAP file...");
|
emit status("Writing intermediate PCAP file...");
|
||||||
isOk = fmt->saveStreams(streams, pcapFile.fileName(), error);
|
isOk = fmt->save(streams, pcapFile.fileName(), error);
|
||||||
|
|
||||||
qDebug("generating PDML %s", fileName.toAscii().constData());
|
qDebug("generating PDML %s", fileName.toAscii().constData());
|
||||||
emit status("Converting PCAP to PDML...");
|
emit status("Converting PCAP to PDML...");
|
||||||
|
@ -27,9 +27,9 @@ public:
|
|||||||
PdmlFileFormat();
|
PdmlFileFormat();
|
||||||
~PdmlFileFormat();
|
~PdmlFileFormat();
|
||||||
|
|
||||||
virtual bool openStreams(const QString fileName,
|
virtual bool open(const QString fileName,
|
||||||
OstProto::StreamConfigList &streams, QString &error);
|
OstProto::StreamConfigList &streams, QString &error);
|
||||||
virtual bool saveStreams(const OstProto::StreamConfigList streams,
|
virtual bool save(const OstProto::StreamConfigList streams,
|
||||||
const QString fileName, QString &error);
|
const QString fileName, QString &error);
|
||||||
|
|
||||||
bool isMyFileFormat(const QString fileName);
|
bool isMyFileFormat(const QString fileName);
|
||||||
|
@ -46,14 +46,14 @@ PythonFileFormat::~PythonFileFormat()
|
|||||||
// Nothing to do
|
// Nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PythonFileFormat::openStreams(const QString /*fileName*/,
|
bool PythonFileFormat::open(const QString /*fileName*/,
|
||||||
OstProto::StreamConfigList &/*streams*/, QString &/*error*/)
|
OstProto::StreamConfigList &/*streams*/, QString &/*error*/)
|
||||||
{
|
{
|
||||||
// NOT SUPPORTED!
|
// NOT SUPPORTED!
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PythonFileFormat::saveStreams(const OstProto::StreamConfigList streams,
|
bool PythonFileFormat::save(const OstProto::StreamConfigList streams,
|
||||||
const QString fileName, QString &error)
|
const QString fileName, QString &error)
|
||||||
{
|
{
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
|
@ -30,9 +30,9 @@ public:
|
|||||||
PythonFileFormat();
|
PythonFileFormat();
|
||||||
~PythonFileFormat();
|
~PythonFileFormat();
|
||||||
|
|
||||||
virtual bool openStreams(const QString fileName,
|
virtual bool open(const QString fileName,
|
||||||
OstProto::StreamConfigList &streams, QString &error);
|
OstProto::StreamConfigList &streams, QString &error);
|
||||||
virtual bool saveStreams(const OstProto::StreamConfigList streams,
|
virtual bool save(const OstProto::StreamConfigList streams,
|
||||||
const QString fileName, QString &error);
|
const QString fileName, QString &error);
|
||||||
|
|
||||||
bool isMyFileFormat(const QString fileName);
|
bool isMyFileFormat(const QString fileName);
|
||||||
|
@ -62,7 +62,7 @@ QStringList StreamFileFormat::supportedFileTypes(Operation op)
|
|||||||
return fileTypes;
|
return fileTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamFileFormat::openStreamsOffline(const QString fileName,
|
void StreamFileFormat::openAsync(const QString fileName,
|
||||||
OstProto::StreamConfigList &streams, QString &error)
|
OstProto::StreamConfigList &streams, QString &error)
|
||||||
{
|
{
|
||||||
fileName_ = fileName;
|
fileName_ = fileName;
|
||||||
@ -74,7 +74,7 @@ void StreamFileFormat::openStreamsOffline(const QString fileName,
|
|||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamFileFormat::saveStreamsOffline(
|
void StreamFileFormat::saveAsync(
|
||||||
const OstProto::StreamConfigList streams,
|
const OstProto::StreamConfigList streams,
|
||||||
const QString fileName, QString &error)
|
const QString fileName, QString &error)
|
||||||
{
|
{
|
||||||
@ -134,7 +134,7 @@ void StreamFileFormat::cancel()
|
|||||||
void StreamFileFormat::run()
|
void StreamFileFormat::run()
|
||||||
{
|
{
|
||||||
if (op_ == kOpenFile)
|
if (op_ == kOpenFile)
|
||||||
result_ = openStreams(fileName_, *openStreams_, *error_);
|
result_ = open(fileName_, *openStreams_, *error_);
|
||||||
else if (op_ == kSaveFile)
|
else if (op_ == kSaveFile)
|
||||||
result_ = saveStreams(saveStreams_, fileName_, *error_);
|
result_ = save(saveStreams_, fileName_, *error_);
|
||||||
}
|
}
|
||||||
|
@ -36,17 +36,17 @@ public:
|
|||||||
StreamFileFormat();
|
StreamFileFormat();
|
||||||
virtual ~StreamFileFormat();
|
virtual ~StreamFileFormat();
|
||||||
|
|
||||||
virtual bool openStreams(const QString fileName,
|
virtual bool open(const QString fileName,
|
||||||
OstProto::StreamConfigList &streams, QString &error) = 0;
|
OstProto::StreamConfigList &streams, QString &error) = 0;
|
||||||
virtual bool saveStreams(const OstProto::StreamConfigList streams,
|
virtual bool save(const OstProto::StreamConfigList streams,
|
||||||
const QString fileName, QString &error) = 0;
|
const QString fileName, QString &error) = 0;
|
||||||
|
|
||||||
virtual QDialog* openOptionsDialog();
|
virtual QDialog* openOptionsDialog();
|
||||||
virtual QDialog* saveOptionsDialog();
|
virtual QDialog* saveOptionsDialog();
|
||||||
|
|
||||||
void openStreamsOffline(const QString fileName,
|
void openAsync(const QString fileName,
|
||||||
OstProto::StreamConfigList &streams, QString &error);
|
OstProto::StreamConfigList &streams, QString &error);
|
||||||
void saveStreamsOffline(const OstProto::StreamConfigList streams,
|
void saveAsync(const OstProto::StreamConfigList streams,
|
||||||
const QString fileName, QString &error);
|
const QString fileName, QString &error);
|
||||||
|
|
||||||
bool result();
|
bool result();
|
||||||
|
Loading…
Reference in New Issue
Block a user