Fix Windows compilation problems from r45513. #ifdef out some non-Windows
code. Get rid of a few uses of the global cfile. svn path=/trunk/; revision=45514
This commit is contained in:
parent
cfa22deaae
commit
419f851e34
|
@ -184,7 +184,7 @@ static gboolean export_text_prefs_init = FALSE;
|
|||
void
|
||||
export_text_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
|
||||
{
|
||||
win32_export_file(GDK_WINDOW_HWND(gtk_widget_get_window(top_level)), export_type_text);
|
||||
win32_export_file(GDK_WINDOW_HWND(gtk_widget_get_window(top_level)), &cfile export_type_text);
|
||||
return;
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <windows.h>
|
||||
#include "packet-range.h"
|
||||
#include "ui/win32/file_dlg_win32.h"
|
||||
#endif
|
||||
#else // Q_WS_WIN
|
||||
|
||||
#include <errno.h>
|
||||
#include "file.h"
|
||||
|
@ -47,6 +47,7 @@
|
|||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QSpacerItem>
|
||||
#endif // Q_WS_WIN
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
@ -244,61 +245,6 @@ check_savability_t CaptureFileDialog::checkSaveAsWithComments(QWidget *
|
|||
#endif // Q_WS_WIN
|
||||
}
|
||||
|
||||
void CaptureFileDialog::addPreview(QVBoxLayout &v_box) {
|
||||
QGridLayout *preview_grid = new QGridLayout();
|
||||
QLabel *lbl;
|
||||
|
||||
preview_labels_.clear();
|
||||
v_box.addLayout(preview_grid);
|
||||
|
||||
preview_grid->setColumnStretch(0, 0);
|
||||
preview_grid->setColumnStretch(1, 10);
|
||||
|
||||
lbl = new QLabel(tr("Format:"));
|
||||
preview_grid->addWidget(lbl, 0, 0);
|
||||
preview_grid->addWidget(&preview_format_, 0, 1);
|
||||
preview_labels_ << lbl << &preview_format_;
|
||||
|
||||
lbl = new QLabel(tr("Size:"));
|
||||
preview_grid->addWidget(lbl, 1, 0);
|
||||
preview_grid->addWidget(&preview_size_, 1, 1);
|
||||
preview_labels_ << lbl << &preview_size_;
|
||||
|
||||
lbl = new QLabel(tr("Packets:"));
|
||||
preview_grid->addWidget(lbl, 2, 0);
|
||||
preview_grid->addWidget(&preview_packets_, 2, 1);
|
||||
preview_labels_ << lbl << &preview_packets_;
|
||||
|
||||
lbl = new QLabel(tr("First Packet:"));
|
||||
preview_grid->addWidget(lbl, 3, 0);
|
||||
preview_grid->addWidget(&preview_first_, 3, 1);
|
||||
preview_labels_ << lbl << &preview_first_;
|
||||
|
||||
lbl = new QLabel(tr("Elapsed Time:"));
|
||||
preview_grid->addWidget(lbl, 4, 0);
|
||||
preview_grid->addWidget(&preview_elapsed_, 4, 1);
|
||||
preview_labels_ << lbl << &preview_elapsed_;
|
||||
|
||||
connect(this, SIGNAL(currentChanged(const QString &)), this, SLOT(preview(const QString &)));
|
||||
|
||||
preview("");
|
||||
}
|
||||
|
||||
void CaptureFileDialog::addMergeControls(QVBoxLayout &v_box) {
|
||||
|
||||
merge_prepend_.setText("Prepend packets");
|
||||
merge_prepend_.setToolTip("Insert packets from the selected file before the current file. Packet timestamps will be ignored.");
|
||||
v_box.addWidget(&merge_prepend_, 0, Qt::AlignTop);
|
||||
|
||||
merge_chrono_.setText("Merge chronologically");
|
||||
merge_chrono_.setToolTip("Insert packets in chronological order.");
|
||||
merge_chrono_.setChecked(true);
|
||||
v_box.addWidget(&merge_chrono_, 0, Qt::AlignTop);
|
||||
|
||||
merge_append_.setText("Append packets");
|
||||
merge_append_.setToolTip("Insert packets from the selected file after the current file. Packet timestamps will be ignored.");
|
||||
v_box.addWidget(&merge_append_, 0, Qt::AlignTop);
|
||||
}
|
||||
|
||||
// You have to use open, merge, saveAs, or exportPackets. We should
|
||||
// probably just make each type a subclass.
|
||||
|
@ -306,62 +252,6 @@ int CaptureFileDialog::exec() {
|
|||
return QDialog::Rejected;
|
||||
}
|
||||
|
||||
QString CaptureFileDialog::fileType(int ft, bool extension_globs)
|
||||
{
|
||||
QString filter;
|
||||
GSList *extensions_list, *extension;
|
||||
|
||||
filter = wtap_file_type_string(ft);
|
||||
|
||||
if (!extension_globs) {
|
||||
return filter;
|
||||
}
|
||||
|
||||
filter += " (";
|
||||
|
||||
extensions_list = wtap_get_file_extensions_list(ft, TRUE);
|
||||
if (extensions_list == NULL) {
|
||||
/* This file type doesn't have any particular extension
|
||||
conventionally used for it, so we'll just use "*.*"
|
||||
as the pattern; on Windows, that matches all file names
|
||||
- even those with no extension - so we don't need to
|
||||
worry about compressed file extensions. (It does not
|
||||
do so on UN*X; the right pattern on UN*X would just
|
||||
be "*".) */
|
||||
filter += "*.*";
|
||||
} else {
|
||||
/* Construct the list of patterns. */
|
||||
for (extension = extensions_list; extension != NULL;
|
||||
extension = g_slist_next(extension)) {
|
||||
if (!filter.endsWith('('))
|
||||
filter += ' ';
|
||||
filter += "*.";
|
||||
filter += (char *)extension->data;
|
||||
}
|
||||
wtap_free_file_extensions_list(extensions_list);
|
||||
}
|
||||
filter += ')';
|
||||
return filter;
|
||||
/* XXX - does QStringList's destructor destroy the strings in the list? */
|
||||
}
|
||||
|
||||
QStringList CaptureFileDialog::buildFileOpenTypeList() {
|
||||
QStringList filters;
|
||||
int ft;
|
||||
|
||||
/* Add the "All Files" entry. */
|
||||
filters << QString(tr("All Files (*.*)"));
|
||||
|
||||
/* Include all the file types Wireshark supports. */
|
||||
for (ft = 0; ft < WTAP_NUM_FILE_TYPES; ft++) {
|
||||
if (ft == WTAP_FILE_UNKNOWN)
|
||||
continue; /* not a real file type */
|
||||
|
||||
filters << fileType(ft);
|
||||
}
|
||||
|
||||
return filters;
|
||||
}
|
||||
|
||||
|
||||
// Windows
|
||||
|
@ -441,6 +331,119 @@ int CaptureFileDialog::mergeType() {
|
|||
}
|
||||
|
||||
#else // not Q_WS_WINDOWS
|
||||
QString CaptureFileDialog::fileType(int ft, bool extension_globs)
|
||||
{
|
||||
QString filter;
|
||||
GSList *extensions_list, *extension;
|
||||
|
||||
filter = wtap_file_type_string(ft);
|
||||
|
||||
if (!extension_globs) {
|
||||
return filter;
|
||||
}
|
||||
|
||||
filter += " (";
|
||||
|
||||
extensions_list = wtap_get_file_extensions_list(ft, TRUE);
|
||||
if (extensions_list == NULL) {
|
||||
/* This file type doesn't have any particular extension
|
||||
conventionally used for it, so we'll just use "*.*"
|
||||
as the pattern; on Windows, that matches all file names
|
||||
- even those with no extension - so we don't need to
|
||||
worry about compressed file extensions. (It does not
|
||||
do so on UN*X; the right pattern on UN*X would just
|
||||
be "*".) */
|
||||
filter += "*.*";
|
||||
} else {
|
||||
/* Construct the list of patterns. */
|
||||
for (extension = extensions_list; extension != NULL;
|
||||
extension = g_slist_next(extension)) {
|
||||
if (!filter.endsWith('('))
|
||||
filter += ' ';
|
||||
filter += "*.";
|
||||
filter += (char *)extension->data;
|
||||
}
|
||||
wtap_free_file_extensions_list(extensions_list);
|
||||
}
|
||||
filter += ')';
|
||||
return filter;
|
||||
/* XXX - does QStringList's destructor destroy the strings in the list? */
|
||||
}
|
||||
|
||||
QStringList CaptureFileDialog::buildFileOpenTypeList() {
|
||||
QStringList filters;
|
||||
int ft;
|
||||
|
||||
/* Add the "All Files" entry. */
|
||||
filters << QString(tr("All Files (*.*)"));
|
||||
|
||||
/* Include all the file types Wireshark supports. */
|
||||
for (ft = 0; ft < WTAP_NUM_FILE_TYPES; ft++) {
|
||||
if (ft == WTAP_FILE_UNKNOWN)
|
||||
continue; /* not a real file type */
|
||||
|
||||
filters << fileType(ft);
|
||||
}
|
||||
|
||||
return filters;
|
||||
}
|
||||
|
||||
void CaptureFileDialog::addPreview(QVBoxLayout &v_box) {
|
||||
QGridLayout *preview_grid = new QGridLayout();
|
||||
QLabel *lbl;
|
||||
|
||||
preview_labels_.clear();
|
||||
v_box.addLayout(preview_grid);
|
||||
|
||||
preview_grid->setColumnStretch(0, 0);
|
||||
preview_grid->setColumnStretch(1, 10);
|
||||
|
||||
lbl = new QLabel(tr("Format:"));
|
||||
preview_grid->addWidget(lbl, 0, 0);
|
||||
preview_grid->addWidget(&preview_format_, 0, 1);
|
||||
preview_labels_ << lbl << &preview_format_;
|
||||
|
||||
lbl = new QLabel(tr("Size:"));
|
||||
preview_grid->addWidget(lbl, 1, 0);
|
||||
preview_grid->addWidget(&preview_size_, 1, 1);
|
||||
preview_labels_ << lbl << &preview_size_;
|
||||
|
||||
lbl = new QLabel(tr("Packets:"));
|
||||
preview_grid->addWidget(lbl, 2, 0);
|
||||
preview_grid->addWidget(&preview_packets_, 2, 1);
|
||||
preview_labels_ << lbl << &preview_packets_;
|
||||
|
||||
lbl = new QLabel(tr("First Packet:"));
|
||||
preview_grid->addWidget(lbl, 3, 0);
|
||||
preview_grid->addWidget(&preview_first_, 3, 1);
|
||||
preview_labels_ << lbl << &preview_first_;
|
||||
|
||||
lbl = new QLabel(tr("Elapsed Time:"));
|
||||
preview_grid->addWidget(lbl, 4, 0);
|
||||
preview_grid->addWidget(&preview_elapsed_, 4, 1);
|
||||
preview_labels_ << lbl << &preview_elapsed_;
|
||||
|
||||
connect(this, SIGNAL(currentChanged(const QString &)), this, SLOT(preview(const QString &)));
|
||||
|
||||
preview("");
|
||||
}
|
||||
|
||||
void CaptureFileDialog::addMergeControls(QVBoxLayout &v_box) {
|
||||
|
||||
merge_prepend_.setText("Prepend packets");
|
||||
merge_prepend_.setToolTip("Insert packets from the selected file before the current file. Packet timestamps will be ignored.");
|
||||
v_box.addWidget(&merge_prepend_, 0, Qt::AlignTop);
|
||||
|
||||
merge_chrono_.setText("Merge chronologically");
|
||||
merge_chrono_.setToolTip("Insert packets in chronological order.");
|
||||
merge_chrono_.setChecked(true);
|
||||
v_box.addWidget(&merge_chrono_, 0, Qt::AlignTop);
|
||||
|
||||
merge_append_.setText("Append packets");
|
||||
merge_append_.setToolTip("Insert packets from the selected file after the current file. Packet timestamps will be ignored.");
|
||||
v_box.addWidget(&merge_append_, 0, Qt::AlignTop);
|
||||
}
|
||||
|
||||
int CaptureFileDialog::selectedFileType() {
|
||||
return type_hash_.value(selectedNameFilter(), -1);
|
||||
}
|
||||
|
|
|
@ -74,6 +74,10 @@ public:
|
|||
bool isCompressed();
|
||||
|
||||
private:
|
||||
capture_file *cap_file_;
|
||||
QString &display_filter_;
|
||||
|
||||
#if !defined(Q_WS_WIN)
|
||||
void addMergeControls(QVBoxLayout &v_box);
|
||||
void addDisplayFilterEdit();
|
||||
void addPreview(QVBoxLayout &v_box);
|
||||
|
@ -83,8 +87,6 @@ private:
|
|||
QVBoxLayout left_v_box_;
|
||||
QVBoxLayout right_v_box_;
|
||||
|
||||
QString &display_filter_;
|
||||
capture_file *cap_file_;
|
||||
DisplayFilterEdit* display_filter_edit_;
|
||||
int last_row_;
|
||||
|
||||
|
@ -101,7 +103,6 @@ private:
|
|||
|
||||
QHash<QString, int>type_hash_;
|
||||
|
||||
#if !defined(Q_WS_WIN)
|
||||
void addResolutionControls(QVBoxLayout &v_box);
|
||||
void addGzipControls(QVBoxLayout &v_box);
|
||||
void addRangeControls(QVBoxLayout &v_box, packet_range_t *range);
|
||||
|
|
|
@ -23,7 +23,11 @@
|
|||
|
||||
#include "export_dissection_dialog.h"
|
||||
|
||||
#if !defined(Q_WS_WIN)
|
||||
#ifdef Q_WS_WIN
|
||||
#include <windows.h>
|
||||
#include "packet-range.h"
|
||||
#include "ui/win32/file_dlg_win32.h"
|
||||
#else // Q_WS_WIN
|
||||
#include "print.h"
|
||||
|
||||
#include "ui/alert_box.h"
|
||||
|
@ -43,11 +47,13 @@
|
|||
#include <QDebug>
|
||||
#endif // Q_WS_WIN
|
||||
|
||||
ExportDissectionDialog::ExportDissectionDialog(QWidget *parent, export_type_e export_type, capture_file *cap_file):
|
||||
ExportDissectionDialog::ExportDissectionDialog(QWidget *parent, capture_file *cap_file, export_type_e export_type):
|
||||
QFileDialog(parent),
|
||||
export_type_(export_type),
|
||||
cap_file_(cap_file),
|
||||
save_bt_(NULL)
|
||||
export_type_(export_type)
|
||||
#if !defined(Q_WS_WIN)
|
||||
, save_bt_(NULL)
|
||||
#endif Q_WS_WIN
|
||||
{
|
||||
#if !defined(Q_WS_WIN)
|
||||
QDialogButtonBox *button_box = findChild<QDialogButtonBox *>();
|
||||
|
@ -198,11 +204,12 @@ int ExportDissectionDialog::exec()
|
|||
|
||||
return retval;
|
||||
#else // Q_WS_WIN
|
||||
win32_export_file(parent->effectiveWinId(), export_type_);
|
||||
win32_export_file(parentWidget()->effectiveWinId(), cap_file_, export_type_);
|
||||
return QDialog::Accepted;
|
||||
#endif // Q_WS_WIN
|
||||
}
|
||||
|
||||
#ifndef Q_WS_WIN
|
||||
void ExportDissectionDialog::exportTypeChanged(QString name_filter)
|
||||
{
|
||||
export_type_ = export_type_map_.value(name_filter);
|
||||
|
@ -234,16 +241,4 @@ void ExportDissectionDialog::checkValidity()
|
|||
|
||||
save_bt_->setEnabled(enable);
|
||||
}
|
||||
|
||||
//#if !defined(Q_WS_WIN)
|
||||
//void ExportDissectionDialog::on_buttonBox_helpRequested()
|
||||
//{
|
||||
// gchar *url = topic_action_url(HELP_EXPORT_FILE_DIALOG);
|
||||
|
||||
// if(url != NULL) {
|
||||
// QDesktopServices::openUrl(QUrl(url));
|
||||
// g_free(url);
|
||||
// }
|
||||
//}
|
||||
|
||||
//#endif // Q_WS_WIN
|
||||
#endif // Q_WS_WIN
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
#include "ui/file_dialog.h"
|
||||
|
||||
#ifndef Q_WS_WIN
|
||||
#import "packet_range_group_box.h"
|
||||
#import "packet_format_group_box.h"
|
||||
#include "packet_range_group_box.h"
|
||||
#include "packet_format_group_box.h"
|
||||
#endif // Q_WS_WIN
|
||||
|
||||
#include <QFileDialog>
|
||||
|
@ -45,20 +45,22 @@ class ExportDissectionDialog : public QFileDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ExportDissectionDialog(QWidget *parent, export_type_e export_type, capture_file *cap_file);
|
||||
explicit ExportDissectionDialog(QWidget *parent, capture_file *cap_file, export_type_e export_type);
|
||||
~ExportDissectionDialog();
|
||||
|
||||
public slots:
|
||||
int exec();
|
||||
|
||||
private slots:
|
||||
#ifndef Q_WS_WIN
|
||||
void exportTypeChanged(QString name_filter);
|
||||
void checkValidity();
|
||||
#endif // Q_WS_WIN
|
||||
|
||||
private:
|
||||
export_type_e export_type_;
|
||||
#if !defined(Q_WS_WIN)
|
||||
capture_file *cap_file_;
|
||||
#ifndef Q_WS_WIN
|
||||
print_args_t print_args_;
|
||||
|
||||
QMap<QString, export_type_e> export_type_map_;
|
||||
|
|
|
@ -838,8 +838,7 @@ void MainWindow::exportSelectedPackets() {
|
|||
}
|
||||
|
||||
void MainWindow::exportDissections(export_type_e export_type) {
|
||||
QString file_name = "";
|
||||
ExportDissectionDialog ed_dlg(this, export_type, cap_file_);
|
||||
ExportDissectionDialog ed_dlg(this, cap_file_, export_type);
|
||||
packet_range_t range;
|
||||
|
||||
if (!cap_file_)
|
||||
|
|
|
@ -605,7 +605,7 @@ win32_merge_file (HWND h_wnd, GString *file_name, GString *display_filter, int *
|
|||
}
|
||||
|
||||
void
|
||||
win32_export_file(HWND h_wnd, export_type_e export_type) {
|
||||
win32_export_file(HWND h_wnd, capture_file *cf, export_type_e export_type) {
|
||||
OPENFILENAME *ofn;
|
||||
TCHAR file_name[MAX_PATH] = _T("");
|
||||
char *dirname;
|
||||
|
@ -670,7 +670,7 @@ win32_export_file(HWND h_wnd, export_type_e export_type) {
|
|||
g_free( (void *) ofn);
|
||||
return;
|
||||
}
|
||||
status = cf_print_packets(&cfile, &print_args);
|
||||
status = cf_print_packets(cf, &print_args);
|
||||
break;
|
||||
case export_type_ps: /* PostScript (r) */
|
||||
print_args.stream = print_stream_ps_new(TRUE, print_args.file);
|
||||
|
@ -679,19 +679,19 @@ win32_export_file(HWND h_wnd, export_type_e export_type) {
|
|||
g_free( (void *) ofn);
|
||||
return;
|
||||
}
|
||||
status = cf_print_packets(&cfile, &print_args);
|
||||
status = cf_print_packets(cf, &print_args);
|
||||
break;
|
||||
case export_type_csv: /* CSV */
|
||||
status = cf_write_csv_packets(&cfile, &print_args);
|
||||
status = cf_write_csv_packets(cf, &print_args);
|
||||
break;
|
||||
case export_type_carrays: /* C Arrays */
|
||||
status = cf_write_carrays_packets(&cfile, &print_args);
|
||||
status = cf_write_carrays_packets(cf, &print_args);
|
||||
break;
|
||||
case export_type_psml: /* PSML */
|
||||
status = cf_write_psml_packets(&cfile, &print_args);
|
||||
status = cf_write_psml_packets(cf, &print_args);
|
||||
break;
|
||||
case export_type_pdml: /* PDML */
|
||||
status = cf_write_pdml_packets(&cfile, &print_args);
|
||||
status = cf_write_pdml_packets(cf, &print_args);
|
||||
break;
|
||||
default:
|
||||
g_free( (void *) ofn);
|
||||
|
|
|
@ -93,7 +93,7 @@ gboolean win32_merge_file (HWND h_wnd, GString *file_name, GString *display_filt
|
|||
* @param h_wnd HWND of the parent window.
|
||||
* @param export_type The export type.
|
||||
*/
|
||||
void win32_export_file (HWND h_wnd, export_type_e export_type);
|
||||
void win32_export_file (HWND h_wnd, capture_file *cf, export_type_e export_type);
|
||||
|
||||
/** Open the "Export raw bytes" dialog box.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue