diff --git a/client/port.cpp b/client/port.cpp index 7f3b275..1bbe616 100644 --- a/client/port.cpp +++ b/client/port.cpp @@ -19,8 +19,8 @@ along with this program. If not, see #include "port.h" -#include "abstractfileformat.h" #include "emulation.h" +#include "streamfileformat.h" #include #include @@ -553,7 +553,7 @@ bool Port::openStreams(QString fileName, bool append, QString &error) QDialog *optDialog; QProgressDialog progress("Opening Streams", "Cancel", 0, 0, mainWindow); OstProto::StreamConfigList streams; - AbstractFileFormat *fmt = AbstractFileFormat::fileFormatFromFile(fileName); + StreamFileFormat *fmt = StreamFileFormat::fileFormatFromFile(fileName); if (fmt == NULL) { error = tr("Unknown streams file format"); @@ -642,7 +642,7 @@ bool Port::saveStreams(QString fileName, QString fileType, QString &error) { bool ret = false; QProgressDialog progress("Saving Streams", "Cancel", 0, 0, mainWindow); - AbstractFileFormat *fmt = AbstractFileFormat::fileFormatFromType(fileType); + StreamFileFormat *fmt = StreamFileFormat::fileFormatFromType(fileType); OstProto::StreamConfigList streams; if (fmt == NULL) diff --git a/client/portswindow.cpp b/client/portswindow.cpp index 87793a7..4c85150 100644 --- a/client/portswindow.cpp +++ b/client/portswindow.cpp @@ -19,11 +19,11 @@ along with this program. If not, see #include "portswindow.h" -#include "abstractfileformat.h" #include "deviceswidget.h" #include "portconfigdialog.h" #include "settings.h" #include "streamconfigdialog.h" +#include "streamfileformat.h" #include "streamlistdelegate.h" #include "fileformat.pb.h" @@ -812,8 +812,8 @@ void PortsWindow::on_actionOpen_Streams_triggered() { qDebug("Open Streams Action"); - QStringList fileTypes = AbstractFileFormat::supportedFileTypes( - AbstractFileFormat::kOpenFile); + QStringList fileTypes = StreamFileFormat::supportedFileTypes( + StreamFileFormat::kOpenFile); QString fileType; QModelIndex current = tvPortList->selectionModel()->currentIndex(); static QString dirName; @@ -885,8 +885,8 @@ void PortsWindow::on_actionSave_Streams_triggered() QModelIndex current = tvPortList->selectionModel()->currentIndex(); static QString fileName; - QStringList fileTypes = AbstractFileFormat::supportedFileTypes( - AbstractFileFormat::kSaveFile); + QStringList fileTypes = StreamFileFormat::supportedFileTypes( + StreamFileFormat::kSaveFile); QString fileType; QString errorStr; QFileDialog::Options options; diff --git a/common/fileformat.cpp b/common/ostmfileformat.cpp similarity index 85% rename from common/fileformat.cpp rename to common/ostmfileformat.cpp index 36c3eac..7da2685 100644 --- a/common/fileformat.cpp +++ b/common/ostmfileformat.cpp @@ -17,17 +17,17 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -#include "fileformat.h" +#include "ostmfileformat.h" -FileFormat fileFormat; +OstmFileFormat fileFormat; -FileFormat::FileFormat() - : AbstractFileFormat(), NativeFileFormat() +OstmFileFormat::OstmFileFormat() + : StreamFileFormat(), NativeFileFormat() { // Do Nothing! } -bool FileFormat::openStreams(const QString fileName, +bool OstmFileFormat::openStreams(const QString fileName, OstProto::StreamConfigList &streams, QString &error) { OstProto::FileMeta meta; @@ -54,7 +54,7 @@ _fail: return false; } -bool FileFormat::saveStreams(const OstProto::StreamConfigList streams, +bool OstmFileFormat::saveStreams(const OstProto::StreamConfigList streams, const QString fileName, QString &error) { OstProto::FileContent content; @@ -79,12 +79,12 @@ _fail: return false; } -bool FileFormat::isMyFileFormat(const QString fileName) +bool OstmFileFormat::isMyFileFormat(const QString fileName) { return isNativeFileFormat(fileName, OstProto::kStreamsFileType); } -bool FileFormat::isMyFileType(const QString fileType) +bool OstmFileFormat::isMyFileType(const QString fileType) { if (fileType.startsWith("Ostinato")) return true; diff --git a/common/fileformat.h b/common/ostmfileformat.h similarity index 83% rename from common/fileformat.h rename to common/ostmfileformat.h index 95eb310..33332a8 100644 --- a/common/fileformat.h +++ b/common/ostmfileformat.h @@ -16,18 +16,18 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see */ -#ifndef _FILE_FORMAT_H -#define _FILE_FORMAT_H +#ifndef _OSTM_FILE_FORMAT_H +#define _OSTM_FILE_FORMAT_H -#include "abstractfileformat.h" #include "nativefileformat.h" +#include "streamfileformat.h" #include "fileformat.pb.h" -class FileFormat : public AbstractFileFormat, public NativeFileFormat +class OstmFileFormat : public StreamFileFormat, public NativeFileFormat { public: - FileFormat(); + OstmFileFormat(); virtual bool openStreams(const QString fileName, OstProto::StreamConfigList &streams, QString &error); @@ -38,6 +38,6 @@ public: bool isMyFileType(const QString fileType); }; -extern FileFormat fileFormat; +extern OstmFileFormat fileFormat; #endif diff --git a/common/ostprotogui.pro b/common/ostprotogui.pro index 44f1061..7785def 100644 --- a/common/ostprotogui.pro +++ b/common/ostprotogui.pro @@ -35,12 +35,11 @@ PROTOS = \ # TODO: Move fileformat related stuff into a different library - why? HEADERS = \ ostprotolib.h \ - abstractfileformat.h \ - fileformat.h \ ipv4addressdelegate.h \ ipv6addressdelegate.h \ nativefileformat.h \ ossnfileformat.h \ + ostmfileformat.h \ pcapfileformat.h \ pdmlfileformat.h \ pythonfileformat.h \ @@ -48,6 +47,7 @@ HEADERS = \ pdmlprotocols.h \ pdmlreader.h \ sessionfileformat.h \ + streamfileformat.h \ spinboxdelegate.h HEADERS += \ @@ -83,10 +83,9 @@ HEADERS += \ SOURCES += \ ostprotolib.cpp \ - abstractfileformat.cpp \ - fileformat.cpp \ nativefileformat.cpp \ ossnfileformat.cpp \ + ostmfileformat.cpp \ pcapfileformat.cpp \ pdmlfileformat.cpp \ pythonfileformat.cpp \ @@ -94,6 +93,7 @@ SOURCES += \ pdmlprotocols.cpp \ pdmlreader.cpp \ sessionfileformat.cpp \ + streamfileformat.cpp \ spinboxdelegate.cpp SOURCES += \ diff --git a/common/pcapfileformat.h b/common/pcapfileformat.h index 064aaf1..64b03ac 100644 --- a/common/pcapfileformat.h +++ b/common/pcapfileformat.h @@ -19,7 +19,7 @@ along with this program. If not, see #ifndef _PCAP_FILE_FORMAT_H #define _PCAP_FILE_FORMAT_H -#include "abstractfileformat.h" +#include "streamfileformat.h" #include "ui_pcapfileimport.h" #include @@ -39,7 +39,7 @@ private: }; class PdmlReader; -class PcapFileFormat : public AbstractFileFormat +class PcapFileFormat : public StreamFileFormat { friend class PdmlReader; diff --git a/common/pdmlfileformat.cpp b/common/pdmlfileformat.cpp index e567d99..7f0871b 100644 --- a/common/pdmlfileformat.cpp +++ b/common/pdmlfileformat.cpp @@ -80,7 +80,7 @@ bool PdmlFileFormat::saveStreams(const OstProto::StreamConfigList streams, { bool isOk = false; QTemporaryFile pcapFile; - AbstractFileFormat *fmt = AbstractFileFormat::fileFormatFromType("PCAP"); + StreamFileFormat *fmt = StreamFileFormat::fileFormatFromType("PCAP"); QProcess tshark; Q_ASSERT(fmt); diff --git a/common/pdmlfileformat.h b/common/pdmlfileformat.h index e05026a..6621222 100644 --- a/common/pdmlfileformat.h +++ b/common/pdmlfileformat.h @@ -19,9 +19,9 @@ along with this program. If not, see #ifndef _PDML_FILE_FORMAT_H #define _PDML_FILE_FORMAT_H -#include "abstractfileformat.h" +#include "streamfileformat.h" -class PdmlFileFormat : public AbstractFileFormat +class PdmlFileFormat : public StreamFileFormat { public: PdmlFileFormat(); diff --git a/common/pythonfileformat.h b/common/pythonfileformat.h index 55a6452..f45f1d5 100644 --- a/common/pythonfileformat.h +++ b/common/pythonfileformat.h @@ -20,11 +20,11 @@ along with this program. If not, see #ifndef _PYTHON_FILE_FORMAT_H #define _PYTHON_FILE_FORMAT_H -#include "abstractfileformat.h" +#include "streamfileformat.h" #include -class PythonFileFormat : public AbstractFileFormat +class PythonFileFormat : public StreamFileFormat { public: PythonFileFormat(); diff --git a/common/abstractfileformat.cpp b/common/streamfileformat.cpp similarity index 79% rename from common/abstractfileformat.cpp rename to common/streamfileformat.cpp index ebaba93..a074aab 100644 --- a/common/abstractfileformat.cpp +++ b/common/streamfileformat.cpp @@ -17,35 +17,35 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -#include "abstractfileformat.h" +#include "streamfileformat.h" -#include "fileformat.h" +#include "ostmfileformat.h" #include "pcapfileformat.h" #include "pdmlfileformat.h" #include "pythonfileformat.h" #include -AbstractFileFormat::AbstractFileFormat() +StreamFileFormat::StreamFileFormat() { stop_ = false; } -AbstractFileFormat::~AbstractFileFormat() +StreamFileFormat::~StreamFileFormat() { } -QDialog* AbstractFileFormat::openOptionsDialog() +QDialog* StreamFileFormat::openOptionsDialog() { return NULL; } -QDialog* AbstractFileFormat::saveOptionsDialog() +QDialog* StreamFileFormat::saveOptionsDialog() { return NULL; } -QStringList AbstractFileFormat::supportedFileTypes(Operation op) +QStringList StreamFileFormat::supportedFileTypes(Operation op) { QStringList fileTypes; @@ -62,7 +62,7 @@ QStringList AbstractFileFormat::supportedFileTypes(Operation op) return fileTypes; } -void AbstractFileFormat::openStreamsOffline(const QString fileName, +void StreamFileFormat::openStreamsOffline(const QString fileName, OstProto::StreamConfigList &streams, QString &error) { fileName_ = fileName; @@ -74,7 +74,7 @@ void AbstractFileFormat::openStreamsOffline(const QString fileName, start(); } -void AbstractFileFormat::saveStreamsOffline( +void StreamFileFormat::saveStreamsOffline( const OstProto::StreamConfigList streams, const QString fileName, QString &error) { @@ -87,12 +87,12 @@ void AbstractFileFormat::saveStreamsOffline( start(); } -bool AbstractFileFormat::result() +bool StreamFileFormat::result() { return result_; } -AbstractFileFormat* AbstractFileFormat::fileFormatFromFile( +StreamFileFormat* StreamFileFormat::fileFormatFromFile( const QString fileName) { if (fileFormat.isMyFileFormat(fileName)) @@ -107,7 +107,7 @@ AbstractFileFormat* AbstractFileFormat::fileFormatFromFile( return NULL; } -AbstractFileFormat* AbstractFileFormat::fileFormatFromType( +StreamFileFormat* StreamFileFormat::fileFormatFromType( const QString fileType) { @@ -126,12 +126,12 @@ AbstractFileFormat* AbstractFileFormat::fileFormatFromType( return NULL; } -void AbstractFileFormat::cancel() +void StreamFileFormat::cancel() { stop_ = true; } -void AbstractFileFormat::run() +void StreamFileFormat::run() { if (op_ == kOpenFile) result_ = openStreams(fileName_, *openStreams_, *error_); diff --git a/common/abstractfileformat.h b/common/streamfileformat.h similarity index 86% rename from common/abstractfileformat.h rename to common/streamfileformat.h index 0cbb886..d8662d5 100644 --- a/common/abstractfileformat.h +++ b/common/streamfileformat.h @@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -#ifndef _ABSTRACT_FILE_FORMAT_H -#define _ABSTRACT_FILE_FORMAT_H +#ifndef _STREAM_FILE_FORMAT_H +#define _STREAM_FILE_FORMAT_H #include "protocol.pb.h" @@ -27,14 +27,14 @@ along with this program. If not, see class QDialog; -class AbstractFileFormat : public QThread +class StreamFileFormat : public QThread { Q_OBJECT public: enum Operation { kOpenFile, kSaveFile }; - AbstractFileFormat(); - virtual ~AbstractFileFormat(); + StreamFileFormat(); + virtual ~StreamFileFormat(); virtual bool openStreams(const QString fileName, OstProto::StreamConfigList &streams, QString &error) = 0; @@ -53,8 +53,8 @@ public: static QStringList supportedFileTypes(Operation op); - static AbstractFileFormat* fileFormatFromFile(const QString fileName); - static AbstractFileFormat* fileFormatFromType(const QString fileType); + static StreamFileFormat* fileFormatFromFile(const QString fileName); + static StreamFileFormat* fileFormatFromType(const QString fileType); #if 0 bool isMyFileFormat(const QString fileName) = 0;