Class: Watobo::Gui::ConversationTable
- Inherits:
-
FXTable
- Object
- FXTable
- Watobo::Gui::ConversationTable
- Includes:
- Icons
- Defined in:
- lib/watobo/gui/conversation_table.rb
Constant Summary
Constants included from Icons
Icons::ICON_ADD_PROJECT, Icons::ICON_BROWSER_MEDIUM, Icons::ICON_BROWSER_SMALL, Icons::ICON_BTN_DOWN, Icons::ICON_BTN_UP, Icons::ICON_CB_CHECKED, Icons::ICON_CB_CHECKED_ORANGE, Icons::ICON_CB_UNCHECKED, Icons::ICON_CONVERSATION, Icons::ICON_DASHBOARD, Icons::ICON_DIFFER, Icons::ICON_FOLDER, Icons::ICON_FOLDER_SMALL, Icons::ICON_FUZZER, Icons::ICON_FUZZER_MEDIUM, Icons::ICON_FUZZER_SMALL, Icons::ICON_FUZZ_FILTER, Icons::ICON_FUZZ_GENERATOR, Icons::ICON_FUZZ_TAG, Icons::ICON_HINTS, Icons::ICON_HINTS_INFO, Icons::ICON_HINTS_INFO_SMALL, Icons::ICON_HINTS_SMALL, Icons::ICON_INFO, Icons::ICON_INFO_INFO, Icons::ICON_INFO_INFO_SMALL, Icons::ICON_INFO_SMALL, Icons::ICON_INFO_USER, Icons::ICON_INFO_USER_SMALL, Icons::ICON_INTERCEPTOR, Icons::ICON_LOGIN_WIZZARD, Icons::ICON_MANUAL_REQUEST, Icons::ICON_MANUAL_REQUEST_MEDIUM, Icons::ICON_MANUAL_REQUEST_SMALL, Icons::ICON_PAUSE, Icons::ICON_PLUGIN, Icons::ICON_PROJECT, Icons::ICON_PROJECT_SMALL, Icons::ICON_REPORT, Icons::ICON_REQUEST, Icons::ICON_REQUEST_SMALL, Icons::ICON_SEND_REQUEST, Icons::ICON_SITE, Icons::ICON_SITE_SMALL, Icons::ICON_START, Icons::ICON_STOP, Icons::ICON_TOKEN, Icons::ICON_TRANSCODER, Icons::ICON_VULN, Icons::ICON_VULN_BP, Icons::ICON_VULN_BP_SMALL, Icons::ICON_VULN_CRITICAL, Icons::ICON_VULN_CRITICAL_SMALL, Icons::ICON_VULN_HIGH, Icons::ICON_VULN_HIGH_SMALL, Icons::ICON_VULN_LOW, Icons::ICON_VULN_LOW_SMALL, Icons::ICON_VULN_MEDIUM, Icons::ICON_VULN_MEDIUM_SMALL, Icons::ICON_VULN_SMALL, Icons::ICON_WATOBO, Icons::SIBERAS_ICON, Icons::TBL_ICON_LOCK, Icons::WATOBO_LOGO
Instance Attribute Summary collapse
-
#autoscroll ⇒ Object
Returns the value of attribute autoscroll.
-
#filter ⇒ Object
readonly
class ConversationTable < FXColoredTable.
-
#url_decode ⇒ Object
Returns the value of attribute url_decode.
Instance Method Summary collapse
- #addChat(chat, *prefs) ⇒ Object
- #apply_filter(filter = {}) ⇒ Object
- #chat_visible?(chat) ⇒ Boolean
- #clearConversation ⇒ Object
- #clearEvents(event) ⇒ Object
- #current_chat ⇒ Object
- #initColumns ⇒ Object
-
#initialize(owner, unused = nil) ⇒ ConversationTable
constructor
A new instance of ConversationTable.
- #notify(event, *args) ⇒ Object
- #num_total ⇒ Object
- #num_visible ⇒ Object
- #scrollDown ⇒ Object
- #scrollUp ⇒ Object
- #setNewFont(font_type = nil, size = nil) ⇒ Object
- #showConversation(chat_list = nil, prefs = {}) ⇒ Object
- #start_update_timer ⇒ Object
- #subscribe(event, &callback) ⇒ Object
- #updateComment(row, comment) ⇒ Object
Constructor Details
#initialize(owner, unused = nil) ⇒ ConversationTable
Returns a new instance of ConversationTable.
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/watobo/gui/conversation_table.rb', line 224 def initialize(owner, unused = nil) @event_dispatcher_listeners = Hash.new super(owner, :opts => TABLE_COL_SIZABLE|TABLE_ROW_SIZABLE|LAYOUT_FILL_X|LAYOUT_FILL_Y|TABLE_READONLY|LAYOUT_SIDE_TOP, :padding => 2) @filter = {} @url_decode = true self.setBackColor(FXRGB(255, 255, 255)) self.setCellColor(0, 0, FXRGB(255, 255, 255)) self.setCellColor(0, 1, FXRGB(255, 240, 240)) self.setCellColor(1, 0, FXRGB(240, 255, 240)) self.setCellColor(1, 1, FXRGB(240, 240, 255)) # reset_filter # FXMAPFUNC(SEL_CLICKED, FXTable::ID_SELECT_CELL, :onSelectCell) @current_chat_list = [] @uniq_chats = Hash.new @columns = Hash.new @cell_width = Hash.new @col_order = [] @autoscroll = false @columns = Hash.new @columns[TABLE_COL_METHOD] = "Method" @columns[TABLE_COL_HOST] = "Host" @columns[TABLE_COL_PATH] = "Path" @columns[TABLE_COL_PARMS] = "Parameters" @columns[TABLE_COL_STATUS] = "Status" @columns[TABLE_COL_COOKIE] = "Set-Cookie" @columns[TABLE_COL_COMMENT] = "Comment" @columns[TABLE_COL_SSL] = "" # initialize columns order @col_order = [TABLE_COL_SSL, TABLE_COL_METHOD, TABLE_COL_HOST, TABLE_COL_PATH, TABLE_COL_PARMS, TABLE_COL_STATUS, TABLE_COL_COOKIE, TABLE_COL_COMMENT] # init cell width @cell_width = Hash.new @cell_width[TABLE_COL_METHOD] = 50 @cell_width[TABLE_COL_HOST] = 120 @cell_width[TABLE_COL_PATH] = 200 @cell_width[TABLE_COL_PARMS] = 150 @cell_width[TABLE_COL_STATUS] = 50 @cell_width[TABLE_COL_COOKIE] = 70 @cell_width[TABLE_COL_COMMENT] = 100 @cell_width[TABLE_COL_SSL] = 20 @cell_width_defaults = Hash.new @cell_width_defaults.update YAML.load(YAML.dump(@cell_width)) @cell_auto_max = 400 @cell_min_width = 30 initColumns() self.columnHeader.connect(SEL_CHANGED) do |sender, sel, index| type = @col_order[index] @cell_width[type] = self.getColumnWidth(index) end self.columnHeader.connect(SEL_COMMAND) do |sender, sel, index| type = @col_order[index] column_width = self.getColumnWidth(index) new_width = case column_width when column_width > @cell_auto_max @cell_auto_max when (column_width > @cell_width_defaults[type]) @cell_width_defaults[type] when @cell_width_defaults[type] self.fitColumnsToContents(index) w = self.getColumnWidth(index) w = @cell_auto_max if self.getColumnWidth(index) > @cell_auto_max w = @cell_width_defaults[type] if self.getColumnWidth(index) < @cell_width_defaults[type] w else @cell_width_defaults[type] end self.setColumnWidth(index, new_width) @cell_width[type] = new_width self.rowHeaderMode = 0 adjustCellWidth() end self.connect(SEL_CHANGED) { |sender, sel, item| # puts "SEL_CHANGED #{item.row}" self.selectRow(item.row, false) chat = self.getItemData(item.row, 0) notify(:chat_selected, chat) if chat.respond_to? :request } self.connect(SEL_COMMAND) { |sender, sel, item| # puts "SEL_COMMAND #{item.row}" self.selectRow(item.row, false) chat = self.getItemData(item.row, 0) notify(:chat_selected, chat) if chat.respond_to? :request } self.connect(SEL_DOUBLECLICKED) { |sender, sel, item| # puts "SEL_DOUBLECLICKED #{item.row}" if item.row >= 0 self.selectRow(item.row, false) chat = self.getItemData(item.row, 0) notify(:chat_doubleclicked, chat) if chat.respond_to? :request end } self.connect(SEL_SELECTED) { |sender, sel, item| # puts "SEL_SELECTED #{item.row}" self.selectRow(item.row, false) chat = self.getItemData(item.row, 0) notify(:chat_selected, chat) if chat.respond_to? :request } adjustCellWidth() addHotkeyHandler(self) start_update_timer end |
Instance Attribute Details
#autoscroll ⇒ Object
Returns the value of attribute autoscroll.
62 63 64 |
# File 'lib/watobo/gui/conversation_table.rb', line 62 def autoscroll @autoscroll end |
#filter ⇒ Object (readonly)
class ConversationTable < FXColoredTable
60 61 62 |
# File 'lib/watobo/gui/conversation_table.rb', line 60 def filter @filter end |
#url_decode ⇒ Object
Returns the value of attribute url_decode.
63 64 65 |
# File 'lib/watobo/gui/conversation_table.rb', line 63 def url_decode @url_decode end |
Instance Method Details
#addChat(chat, *prefs) ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/watobo/gui/conversation_table.rb', line 194 def addChat(chat, *prefs) return false if chat.nil? if self.getNumRows <= 0 then clearConversation() # initColumns() end @current_chat_list.push chat if prefs.include? :ignore_filter add_chat_row(chat) return true end add_chat_row(chat) if Chats.match?(chat, @filter) return true end |
#apply_filter(filter = {}) ⇒ Object
94 95 96 97 98 |
# File 'lib/watobo/gui/conversation_table.rb', line 94 def apply_filter(filter={}) @filter = filter puts @filter.to_yaml if $DEBUG update_table end |
#chat_visible?(chat) ⇒ Boolean
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/watobo/gui/conversation_table.rb', line 110 def chat_visible?(chat) begin return false if @filter[:ok_only] == true and chat.response.responseCode !~ /200/ if @filter[:unique] unless Watobo::Gui.project.nil? uniq_hash = Watobo::Gui.project.uniqueRequestHash chat.request return false if @uniq_chats.has_key? uniq_hash @uniq_chats[uniq_hash] = nil end end if @filter[:show_scope_only] unless Watobo::Gui.project.nil? return false unless Watobo::Scope.match_site?(chat.request.site) end end # puts "* passed scope" if @filter[:hide_tested] return false if chat.tested? end # puts "* passed hide tested" unless @filter[:doc_filter].include?(chat.request.doctype) return true if @filter[:text].empty? return true if @filter[:url] == true and chat.request.first =~ /#{@filter[:text]}/i return true if @filter[:request] == true and chat.request.join =~ /#{@filter[:text]}/i # puts @filter.to_yaml # puts chat.response.responseCode if @filter[:response] == true return false if @filter[:text_only] == true and chat.response.content_type !~ /(text|javascript|xml|json)/ return true if chat.response.join.unpack("C*").pack("C*") =~ /#{@filter[:text]}/i end end rescue => bang puts "! could not add chat to table !".upcase # puts chat.id puts bang puts bang.backtrace if $DEBUG end false end |
#clearConversation ⇒ Object
379 380 381 382 383 384 |
# File 'lib/watobo/gui/conversation_table.rb', line 379 def clearConversation() self.clearItems @current_chat_list = [] initColumns() adjustCellWidth() end |
#clearEvents(event) ⇒ Object
71 72 73 74 |
# File 'lib/watobo/gui/conversation_table.rb', line 71 def clearEvents(event) @event_dispatcher_listeners[event] ||= [] @event_dispatcher_listeners[event].clear end |
#current_chat ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/watobo/gui/conversation_table.rb', line 100 def current_chat # puts currentRow if currentRow >= 0 chatid = getRowText(currentRow).to_i chat = Watobo::Chats.get_by_id(chatid) return chat end return nil end |
#initColumns ⇒ Object
211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/watobo/gui/conversation_table.rb', line 211 def initColumns() self.setTableSize(0, @columns.length) self.visibleRows = 20 self.visibleColumns = @columns.length @columns.each do |type, name| index = @col_order.index(type) self.setColumnText(index, name) self.setColumnIcon(@col_order.index(TABLE_COL_SSL), TBL_ICON_LOCK) # puts self.getItem(@col_order.index(col), 0 ).class.to_s end end |
#notify(event, *args) ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/watobo/gui/conversation_table.rb', line 76 def notify(event, *args) if @event_dispatcher_listeners[event] # puts "NOTIFY: #{self}(:#{event}) [#{@event_dispatcher_listeners[event].length}]" if $DEBUG @event_dispatcher_listeners[event].each do |m| m.call(*args) if m.respond_to? :call end end end |
#num_total ⇒ Object
85 86 87 |
# File 'lib/watobo/gui/conversation_table.rb', line 85 def num_total @current_chat_list.length end |
#num_visible ⇒ Object
89 90 91 |
# File 'lib/watobo/gui/conversation_table.rb', line 89 def num_visible self.numRows end |
#scrollDown ⇒ Object
356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/watobo/gui/conversation_table.rb', line 356 def scrollDown() #self.makePositionVisible(self.numRows-1, 0) #puts "[scrollDown] >>" #puts "xPos: #{self.xPosition}" #puts "yPos: #{self.yPosition}" #puts "viewportHeight: #{self.viewportHeight}" #puts "contentHeight: #{self.contentHeight}" #puts "y-diff: #{self.viewportHeight - self.contentHeight}" #puts "---" self.setPosition(self.xPosition, (self. - self.contentHeight)) end |
#scrollUp ⇒ Object
351 352 353 354 |
# File 'lib/watobo/gui/conversation_table.rb', line 351 def scrollUp() #self.makePositionVisible(0, 0) self.setPosition(self.xPosition, 0) end |
#setNewFont(font_type = nil, size = nil) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/watobo/gui/conversation_table.rb', line 170 def setNewFont(font_type=nil, size=nil) begin new_size = size.nil? ? GUI_REGULAR_FONT_SIZE : size new_font_type = font_type.nil? ? "helvetica" : font_type new_font = FXFont.new(getApp(), new_font_type, new_size) new_font.create self.font = new_font self.rowHeader.font = new_font self.defRowHeight = new_size+10 update_table() rescue => bang puts bang puts bang.backtrace if $DEBUG end end |
#showConversation(chat_list = nil, prefs = {}) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/watobo/gui/conversation_table.rb', line 156 def showConversation(chat_list = nil, prefs = {}) clearConversation() if chat_list.nil? Watobo::Chats.each do |chat| addChat(chat, prefs) end else chat_list.each do |chat| addChat(chat, prefs) end end adjustCellWidth() end |
#start_update_timer ⇒ Object
368 369 370 371 372 373 374 375 376 377 |
# File 'lib/watobo/gui/conversation_table.rb', line 368 def start_update_timer @last_row_count = 0 Watobo.save_thread { if self.getNumRows != @last_row_count scrollDown if @autoscroll == true @last_row_count = self.getNumRows end } end |
#subscribe(event, &callback) ⇒ Object
67 68 69 |
# File 'lib/watobo/gui/conversation_table.rb', line 67 def subscribe(event, &callback) (@event_dispatcher_listeners[event] ||= []) << callback end |
#updateComment(row, comment) ⇒ Object
189 190 191 192 |
# File 'lib/watobo/gui/conversation_table.rb', line 189 def updateComment(row, comment) col = @col_order.index(TABLE_COL_COMMENT) self.setItemText(row, col, comment.gsub(/[^[:print:]]/, ' ')) end |