diff options
-rwxr-xr-x | tools/svnadd | 4 | ||||
-rw-r--r-- | ui/gtk/edit_packet_comment_dlg.c | 5 | ||||
-rw-r--r-- | ui/gtk/main_menubar.c | 4 | ||||
-rw-r--r-- | ui/gtk/packet_list.c | 12 | ||||
-rw-r--r-- | ui/gtk/packet_list.h | 2 | ||||
-rw-r--r-- | ui/gtk/packet_panes.c | 2 | ||||
-rw-r--r-- | ui/qt/CMakeLists.txt | 3 | ||||
-rw-r--r-- | ui/qt/Makefile.am | 5 | ||||
-rw-r--r-- | ui/qt/QtShark.pro | 3 | ||||
-rw-r--r-- | ui/qt/main_window.h | 1 | ||||
-rw-r--r-- | ui/qt/main_window_slots.cpp | 14 | ||||
-rw-r--r-- | ui/qt/packet_comment_dialog.cpp | 65 | ||||
-rw-r--r-- | ui/qt/packet_comment_dialog.h | 49 | ||||
-rw-r--r-- | ui/qt/packet_comment_dialog.ui | 70 | ||||
-rw-r--r-- | ui/qt/packet_list.cpp | 81 | ||||
-rw-r--r-- | ui/qt/packet_list.h | 3 | ||||
-rw-r--r-- | ui/qt/proto_tree.cpp | 2 | ||||
-rw-r--r-- | ui/qt/time_shift_dialog.cpp | 1 |
18 files changed, 309 insertions, 17 deletions
diff --git a/tools/svnadd b/tools/svnadd index c4455c0055..fa2d351d7d 100755 --- a/tools/svnadd +++ b/tools/svnadd @@ -63,6 +63,10 @@ do *.gz) svn ps svn:mime-type application/x-gzip $file ;; + *.ui) + svn ps svn:eol-style native $file + svn ps svn:mime-type text/xml $file + ;; *.xml) svn ps svn:keywords Id $file svn ps svn:eol-style native $file diff --git a/ui/gtk/edit_packet_comment_dlg.c b/ui/gtk/edit_packet_comment_dlg.c index 97f2f529f9..d5034c5963 100644 --- a/ui/gtk/edit_packet_comment_dlg.c +++ b/ui/gtk/edit_packet_comment_dlg.c @@ -32,9 +32,6 @@ #include <epan/epan.h> #include <epan/filesystem.h> -#include "../cfile.h" -#include "../file.h" - #include "ui/main_statusbar.h" #include "ui/simple_dialog.h" @@ -132,7 +129,7 @@ edit_packet_comment_dlg (GtkAction *action _U_, gpointer data _U_) GtkWidget *bbox; GtkWidget *ok_bt, *cancel_bt, *help_bt; GtkTextBuffer *buffer; - gchar *opt_comment; + const gchar *opt_comment; gchar *buf_str; edit_or_add_pkt_comment_dlg = dlg_window_new ("Edit or Add Packet Comments"); diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c index 9b206a448a..da345b10aa 100644 --- a/ui/gtk/main_menubar.c +++ b/ui/gtk/main_menubar.c @@ -1525,7 +1525,7 @@ static const GtkActionEntry main_menu_bar_entries[] = { { "/Edit/ConfigurationProfiles", NULL, "_Configuration Profiles...", "<shift><control>A", NULL, G_CALLBACK(profile_dialog_cb) }, { "/Edit/Preferences", GTK_STOCK_PREFERENCES, "_Preferences...", "<shift><control>P", NULL, G_CALLBACK(menus_prefs_cb) }, { "/Edit/EditPacket", NULL, "_Edit Packet", NULL, NULL, G_CALLBACK(edit_window_cb) }, - { "/Edit/AddEditPktComment", WIRESHARK_STOCK_EDIT, "Edit or Add Packet Comment...", NULL, NULL, G_CALLBACK(edit_packet_comment_dlg) }, + { "/Edit/AddEditPktComment", WIRESHARK_STOCK_EDIT, "Packet Comment...", NULL, NULL, G_CALLBACK(edit_packet_comment_dlg) }, { "/View/TimeDisplayFormat", NULL, "_Time Display Format", NULL, NULL, NULL }, @@ -2797,7 +2797,7 @@ static const GtkActionEntry packet_list_menu_popup_action_entries[] = { { "/Set Time Reference", WIRESHARK_STOCK_TIME, "Set Time Reference (toggle)", NULL, NULL, G_CALLBACK(packet_list_menu_set_ref_time_cb) }, { "/TimeShift", WIRESHARK_STOCK_TIME, "Time Shift...", NULL, NULL, G_CALLBACK(time_shift_cb) }, { "/ManuallyResolveAddress", NULL, "Manually Resolve Address", NULL, NULL, G_CALLBACK(manual_addr_resolv_dlg) }, - { "/Edit/AddEditPktComment", WIRESHARK_STOCK_EDIT, "Edit or Add Packet Comment...", NULL, NULL, G_CALLBACK(edit_packet_comment_dlg) }, + { "/Edit/AddEditPktComment", WIRESHARK_STOCK_EDIT, "Packet Comment...", NULL, NULL, G_CALLBACK(edit_packet_comment_dlg) }, { "/Conversation Filter", NULL, "Conversation Filter", NULL, NULL, NULL }, diff --git a/ui/gtk/packet_list.c b/ui/gtk/packet_list.c index 1c5b364415..f3f3407ba7 100644 --- a/ui/gtk/packet_list.c +++ b/ui/gtk/packet_list.c @@ -71,7 +71,10 @@ #include "ui/gtk/old-gtk-compat.h" +#include <wsutil/str_util.h> + #define COLUMN_WIDTH_MIN 40 +#define MAX_COMMENTS_TO_FETCH 20000000 /* Arbitrary */ #define COL_EDIT_COLUMN "column" #define COL_EDIT_FORMAT_CMB "format_cmb" @@ -1682,7 +1685,7 @@ packet_list_copy_summary_cb(gpointer data _U_, copy_summary_type copy_type) g_string_free(text,TRUE); } -gchar * +const gchar * packet_list_get_packet_comment(void) { GtkTreeModel *model; @@ -1714,8 +1717,13 @@ packet_list_return_all_comments(GtkTextBuffer *buffer) gtk_text_buffer_insert_at_cursor (buffer, buf_str, -1); g_free(buf_str); } + if (gtk_text_buffer_get_char_count(buffer) > MAX_COMMENTS_TO_FETCH) { + buf_str = g_strdup_printf("[ Comment text exceeds %s. Stopping. ]", + format_size(MAX_COMMENTS_TO_FETCH, format_size_unit_bytes|format_size_prefix_si)); + gtk_text_buffer_insert_at_cursor (buffer, buf_str, -1); + return; + } } - } void diff --git a/ui/gtk/packet_list.h b/ui/gtk/packet_list.h index c5b269060f..f41f2e08bf 100644 --- a/ui/gtk/packet_list.h +++ b/ui/gtk/packet_list.h @@ -133,7 +133,7 @@ typedef enum { */ void packet_list_copy_summary_cb(gpointer data _U_, copy_summary_type copy_type); -gchar *packet_list_get_packet_comment(void); +const gchar *packet_list_get_packet_comment(void); void packet_list_update_packet_comment(gchar *new_packet_comment); void packet_list_return_all_comments(GtkTextBuffer *buffer); diff --git a/ui/gtk/packet_panes.c b/ui/gtk/packet_panes.c index d327475577..4a6c158d34 100644 --- a/ui/gtk/packet_panes.c +++ b/ui/gtk/packet_panes.c @@ -1127,7 +1127,7 @@ set_ptree_font_all(PangoFontDescription *font) */ static gboolean colors_ok = FALSE; -GdkColor expert_color_comment = {0, 0x0000, 0xffff, 0x0000 }; /* Green */ +GdkColor expert_color_comment = { 0, 0xb7b7, 0xf7f7, 0x7474 }; /* Green */ GdkColor expert_color_chat = { 0, 0x8080, 0xb7b7, 0xf7f7 }; /* light blue */ GdkColor expert_color_note = { 0, 0xa0a0, 0xffff, 0xffff }; /* bright turquoise */ GdkColor expert_color_warn = { 0, 0xf7f7, 0xf2f2, 0x5353 }; /* yellow */ diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt index 922f745ac8..8dbcb09685 100644 --- a/ui/qt/CMakeLists.txt +++ b/ui/qt/CMakeLists.txt @@ -44,6 +44,7 @@ set(QTSHARK_H_SRC main_welcome.h main_window.h monospace_font.h + packet_comment_dialog.h packet_format_group_box.h packet_list.h packet_list_model.h @@ -88,6 +89,7 @@ set(QTSHARK_CPP_SRC main_window.cpp main_window_slots.cpp monospace_font.cpp + packet_comment_dialog.cpp packet_format_group_box.cpp packet_list.cpp packet_list_model.cpp @@ -117,6 +119,7 @@ set(QTSHARK_UI import_text_dialog.ui main_welcome.ui main_window.ui + packet_comment_dialog.ui packet_format_group_box.ui packet_range_group_box.ui print_dialog.ui diff --git a/ui/qt/Makefile.am b/ui/qt/Makefile.am index 13d6a982e8..5d6b661447 100644 --- a/ui/qt/Makefile.am +++ b/ui/qt/Makefile.am @@ -101,6 +101,11 @@ main_window.h: ui_main_window.h ui_main_window.h: main_window.ui uic $< -o $@ +packet_comment_dialog.h: ui_packet_comment_dialog.h + +ui_packet_comment_dialog.h: packet_comment_dialog.ui + uic $< -o $@ + packet_format_group_box.h: ui_packet_format_group_box.h ui_packet_format_group_box.h: packet_format_group_box.ui diff --git a/ui/qt/QtShark.pro b/ui/qt/QtShark.pro index 5381644fae..56a48f0f2b 100644 --- a/ui/qt/QtShark.pro +++ b/ui/qt/QtShark.pro @@ -186,6 +186,7 @@ FORMS += main_window.ui \ file_set_dialog.ui \ import_text_dialog.ui \ main_welcome.ui \ + packet_comment_dialog.ui \ packet_format_group_box.ui \ packet_range_group_box.ui \ print_dialog.ui \ @@ -218,6 +219,7 @@ HEADERS += $$HEADERS_WS_C \ accordion_frame.h \ export_dissection_dialog.h \ export_object_dialog.h \ + packet_comment_dialog.h \ packet_format_group_box.h \ print_dialog.h \ search_frame.h \ @@ -423,6 +425,7 @@ SOURCES += \ main_window.cpp \ main_window_slots.cpp \ monospace_font.cpp \ + packet_comment_dialog.cpp \ packet_format_group_box.cpp \ packet_list.cpp \ packet_list_model.cpp \ diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index 0082616ab0..447664b907 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -220,6 +220,7 @@ private slots: void on_actionEditNextTimeReference_triggered(); void on_actionEditPreviousTimeReference_triggered(); void on_actionEditTimeShift_triggered(); + void on_actionEditPacketComment_triggered(); void on_actionGoGoToPacket_triggered(); void resetPreviousFocus(); diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 18de80f023..eca548976c 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -63,6 +63,7 @@ #include "export_object_dialog.h" #include "print_dialog.h" #include "time_shift_dialog.h" +#include "packet_comment_dialog.h" #include <QMessageBox> #include <QClipboard> @@ -622,8 +623,7 @@ void MainWindow::setMenusForSelectedPacket() // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/EditPacket", // frame_selected); //#endif /* WANT_PACKET_EDITOR */ -// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/AddEditPktComment", -// frame_selected); + main_ui_->actionEditPacketComment->setEnabled(frame_selected); main_ui_->actionEditIgnorePacket->setEnabled(frame_selected); main_ui_->actionEditIgnoreAllDisplayed->setEnabled(have_filtered); @@ -1266,10 +1266,18 @@ void MainWindow::on_actionEditTimeShift_triggered() TimeShiftDialog ts_dialog(this, cap_file_); connect(this, SIGNAL(setCaptureFile(capture_file*)), &ts_dialog, SLOT(setCaptureFile(capture_file*))); - ts_dialog.exec(); } +void MainWindow::on_actionEditPacketComment_triggered() +{ + PacketCommentDialog pc_dialog(this, packet_list_->packetComment()); + if (pc_dialog.exec() == QDialog::Accepted) { + packet_list_->setPacketComment(pc_dialog.text()); + updateForUnsavedChanges(); + } +} + // View Menu // Expand / collapse slots in proto_tree diff --git a/ui/qt/packet_comment_dialog.cpp b/ui/qt/packet_comment_dialog.cpp new file mode 100644 index 0000000000..4ae6073581 --- /dev/null +++ b/ui/qt/packet_comment_dialog.cpp @@ -0,0 +1,65 @@ +/* packet_comment_dialog.cpp + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "packet_comment_dialog.h" +#include "ui_packet_comment_dialog.h" + +#include "wireshark_application.h" + +PacketCommentDialog::PacketCommentDialog(QWidget *parent, QString comment) : + QDialog(parent), + pc_ui_(new Ui::PacketCommentDialog) +{ + pc_ui_->setupUi(this); + + pc_ui_->commentTextEdit->setPlainText(comment); +} + +PacketCommentDialog::~PacketCommentDialog() +{ + delete pc_ui_; +} + +QString PacketCommentDialog::text() +{ + return pc_ui_->commentTextEdit->toPlainText(); +} + +void PacketCommentDialog::on_buttonBox_helpRequested() +{ +// wsApp->helpTopicAction(HELP_PACKET_COMMENT_DIALOG); +} + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ + diff --git a/ui/qt/packet_comment_dialog.h b/ui/qt/packet_comment_dialog.h new file mode 100644 index 0000000000..2822841e0b --- /dev/null +++ b/ui/qt/packet_comment_dialog.h @@ -0,0 +1,49 @@ +/* packet_comment_dialog.h + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef PACKET_COMMENT_DIALOG_H +#define PACKET_COMMENT_DIALOG_H + +#include <QDialog> + +namespace Ui { +class PacketCommentDialog; +} + +class PacketCommentDialog : public QDialog +{ + Q_OBJECT + +public: + explicit PacketCommentDialog(QWidget *parent = 0, QString comment = QString()); + ~PacketCommentDialog(); + QString text(); + +private slots: + void on_buttonBox_helpRequested(); + +private: + Ui::PacketCommentDialog *pc_ui_; +}; + +#endif // PACKET_COMMENT_DIALOG_H diff --git a/ui/qt/packet_comment_dialog.ui b/ui/qt/packet_comment_dialog.ui new file mode 100644 index 0000000000..b886daa1de --- /dev/null +++ b/ui/qt/packet_comment_dialog.ui @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PacketCommentDialog</class> + <widget class="QDialog" name="PacketCommentDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Wireshark: Packet Comment</string> + </property> + <property name="modal"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QPlainTextEdit" name="commentTextEdit"/> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>PacketCommentDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>PacketCommentDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index 9510055aff..f2d5b6c7d6 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -43,6 +43,8 @@ #include "ui/recent_utils.h" #include "ui/ui_util.h" +#include "wsutil/str_util.h" + #include <QTreeWidget> #include <QTabWidget> #include <QTextEdit> @@ -55,6 +57,8 @@ // capture files against packet lists and models. static PacketList *gbl_cur_packet_list = NULL; +const int max_comments_to_fetch_ = 20000000; // Arbitrary + guint packet_list_append(column_info *cinfo, frame_data *fdata, packet_info *pinfo) { @@ -238,7 +242,8 @@ PacketList::PacketList(QWidget *parent) : ctx_menu_.addAction(window()->findChild<QAction *>("actionEditIgnorePacket")); ctx_menu_.addAction(window()->findChild<QAction *>("actionEditSetTimeReference")); ctx_menu_.addAction(window()->findChild<QAction *>("actionEditTimeShift")); -// " <menuitem name='AddEditPktComment' action='/Edit/AddEditPktComment'/>\n" + ctx_menu_.addAction(window()->findChild<QAction *>("actionEditPacketComment")); + ctx_menu_.addSeparator(); // " <menuitem name='ManuallyResolveAddress' action='/ManuallyResolveAddress'/>\n" ctx_menu_.addSeparator(); @@ -488,9 +493,15 @@ void PacketList::setFrameReftime(gboolean set, frame_data *fdata) void PacketList::updateAll() { update(); - if (cap_file_ && selectedIndexes().length() > 0) { + if (!cap_file_) return; + + if (selectedIndexes().length() > 0) { cf_select_packet(cap_file_, selectedIndexes()[0].row()); } + + if (cap_file_->edt && cap_file_->edt->tree) { + proto_tree_->fillProtocolTree(cap_file_->edt->tree); + } } void PacketList::clear() { @@ -601,6 +612,72 @@ QString &PacketList::getFilterFromRowAndColumn() return filter; } +QString PacketList::packetComment() +{ + int row = currentIndex().row(); + frame_data *fdata; + + if (!cap_file_ || !packet_list_model_) return NULL; + + fdata = packet_list_model_->getRowFdata(row); + + if (!fdata) return NULL; + + return QString(fdata->opt_comment); +} + +void PacketList::setPacketComment(QString new_comment) +{ + int row = currentIndex().row(); + frame_data *fdata; + gchar *new_packet_comment = new_comment.toUtf8().data(); + + if (!cap_file_ || !packet_list_model_) return; + + fdata = packet_list_model_->getRowFdata(row); + + if (!fdata) return; + + /* Check if the comment has changed */ + if (fdata->opt_comment) { + if (strcmp(fdata->opt_comment, new_packet_comment) == 0) { + return; + } + } + + /* Check if we are clearing the comment */ + if(new_comment.isEmpty()) { + new_packet_comment = NULL; + } + + /* The comment has changed, let's update it */ + cf_update_packet_comment(cap_file_, fdata, g_strdup(new_packet_comment)); + + updateAll(); +} + +QString PacketList::allPacketComments() +{ + guint32 framenum; + frame_data *fdata; + QString buf_str; + + if (!cap_file_) return buf_str; + + for (framenum = 1; framenum <= cap_file_->count ; framenum++) { + fdata = frame_data_sequence_find(cap_file_->frames, framenum); + if (fdata->opt_comment) { + buf_str.append(QString("Frame %1: %2 \n\n").arg(framenum).arg(fdata->opt_comment)); + } + if (buf_str.length() > max_comments_to_fetch_) { + buf_str.append(QString("[ Comment text exceeds %1. Stopping. ]") + .arg(format_size(max_comments_to_fetch_, format_size_unit_bytes|format_size_prefix_si))); + return buf_str; + } + } + return buf_str; +} + // Slots void PacketList::setCaptureFile(capture_file *cf) diff --git a/ui/qt/packet_list.h b/ui/qt/packet_list.h index 7257b1fa50..739c8116cc 100644 --- a/ui/qt/packet_list.h +++ b/ui/qt/packet_list.h @@ -46,6 +46,9 @@ public: void writeRecent(FILE *rf); bool contextMenuActive(); QString &getFilterFromRowAndColumn(); + QString packetComment(); + void setPacketComment(QString new_comment); + QString allPacketComments(); protected: void showEvent (QShowEvent *event); diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp index c4592041c2..c63b26a149 100644 --- a/ui/qt/proto_tree.cpp +++ b/ui/qt/proto_tree.cpp @@ -36,7 +36,7 @@ #include <QContextMenuEvent> #include <QMainWindow> -QColor expert_color_comment ( 0x00, 0xff, 0x00 ); /* Green */ +QColor expert_color_comment ( 0xb7, 0xf7, 0x74 ); /* Green */ QColor expert_color_chat ( 0x80, 0xb7, 0xf7 ); /* light blue */ QColor expert_color_note ( 0xa0, 0xff, 0xff ); /* bright turquoise */ QColor expert_color_warn ( 0xf7, 0xf2, 0x53 ); /* yellow */ diff --git a/ui/qt/time_shift_dialog.cpp b/ui/qt/time_shift_dialog.cpp index beb3190dda..02127d125b 100644 --- a/ui/qt/time_shift_dialog.cpp +++ b/ui/qt/time_shift_dialog.cpp @@ -31,7 +31,6 @@ #include <QMessageBox> -#include <QDebug> TimeShiftDialog::TimeShiftDialog(QWidget *parent, capture_file *cf) : QDialog(parent), ts_ui_(new Ui::TimeShiftDialog), |