watobo 0.9.8.677

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) hide show
  1. data/bin/watobo_gui.rb +39 -0
  2. data/certificates/cert.pem +19 -0
  3. data/certificates/privkey.pem +15 -0
  4. data/certificates/watobo_dh.key +5 -0
  5. data/config/datastore.yml +5 -0
  6. data/config/forwarding_proxy.yml +12 -0
  7. data/config/general.yml +4 -0
  8. data/config/gui.yml +23 -0
  9. data/config/interceptor.yml +16 -0
  10. data/config/scan_policy.yml +13 -0
  11. data/config/scanner.yml +34 -0
  12. data/icons/Add.ico +0 -0
  13. data/icons/Add_24x24.ico +0 -0
  14. data/icons/Bandwidth.ico +0 -0
  15. data/icons/Bandwidth_24x24.ico +0 -0
  16. data/icons/Mr. Bomb.ico +0 -0
  17. data/icons/Mr. Bomb_16x16.ico +0 -0
  18. data/icons/Mr. Bomb_24x24.ico +0 -0
  19. data/icons/Orange Ball.ico +0 -0
  20. data/icons/Orange Ball_16x16.ico +0 -0
  21. data/icons/Orange Ball_24x24.ico +0 -0
  22. data/icons/Pause.ico +0 -0
  23. data/icons/Play.ico +0 -0
  24. data/icons/Play_24x24.ico +0 -0
  25. data/icons/Red Ball.ico +0 -0
  26. data/icons/Red Ball_16x16.ico +0 -0
  27. data/icons/Red Ball_24x24.ico +0 -0
  28. data/icons/Run.ico +0 -0
  29. data/icons/Stop.ico +0 -0
  30. data/icons/Stop_24x24.ico +0 -0
  31. data/icons/Terminal.ico +0 -0
  32. data/icons/Transfer.ico +0 -0
  33. data/icons/Transfer_16x16.ico +0 -0
  34. data/icons/User.ico +0 -0
  35. data/icons/User_16x16.ico +0 -0
  36. data/icons/User_24x24.ico +0 -0
  37. data/icons/Web Browser.ico +0 -0
  38. data/icons/Web Browser_16x16.ico +0 -0
  39. data/icons/Write Document.ico +0 -0
  40. data/icons/Yellow Ball.ico +0 -0
  41. data/icons/Yellow Ball_16x16.ico +0 -0
  42. data/icons/Yellow Ball_24x24.ico +0 -0
  43. data/icons/advanced.ico +0 -0
  44. data/icons/advanced_16x16.ico +0 -0
  45. data/icons/advanced_24x24.ico +0 -0
  46. data/icons/applications.ico +0 -0
  47. data/icons/applications_16x16.ico +0 -0
  48. data/icons/applications_24x24.ico +0 -0
  49. data/icons/browser_16x16.ico +0 -0
  50. data/icons/browser_24x24.ico +0 -0
  51. data/icons/burn.ico +0 -0
  52. data/icons/burn_16x16.ico +0 -0
  53. data/icons/burn_24x24.ico +0 -0
  54. data/icons/calculator.ico +0 -0
  55. data/icons/calculator_24x24.ico +0 -0
  56. data/icons/cb_checked.ico +0 -0
  57. data/icons/cb_checked_orange.ico +0 -0
  58. data/icons/cb_unchecked.ico +0 -0
  59. data/icons/coin_24x24.ico +0 -0
  60. data/icons/conversation.ico +0 -0
  61. data/icons/conversation_24x24.ico +0 -0
  62. data/icons/engine.ico +0 -0
  63. data/icons/filter.ico +0 -0
  64. data/icons/folder.ico +0 -0
  65. data/icons/folder_16x16.ico +0 -0
  66. data/icons/fuzzer_16x16.ico +0 -0
  67. data/icons/fuzzer_24x24.ico +0 -0
  68. data/icons/go-down_16x16.png +0 -0
  69. data/icons/go-up_16x16.png +0 -0
  70. data/icons/help.ico +0 -0
  71. data/icons/help_16x16.ico +0 -0
  72. data/icons/help_24x24.ico +0 -0
  73. data/icons/iChat.ico +0 -0
  74. data/icons/iChat_16x16.ico +0 -0
  75. data/icons/iChat_24x24.ico +0 -0
  76. data/icons/icons.txt +3 -0
  77. data/icons/info.ico +0 -0
  78. data/icons/info_16x16.ico +0 -0
  79. data/icons/info_24x24.ico +0 -0
  80. data/icons/interceptor_24x24.ico +0 -0
  81. data/icons/lock.ico +0 -0
  82. data/icons/lock_12x12.ico +0 -0
  83. data/icons/lock_16x16.ico +0 -0
  84. data/icons/monitor.ico +0 -0
  85. data/icons/plugin.ico +0 -0
  86. data/icons/plugin_24x24.ico +0 -0
  87. data/icons/scan_16x16.png +0 -0
  88. data/icons/send.ico +0 -0
  89. data/icons/server.ico +0 -0
  90. data/icons/server_16x16.ico +0 -0
  91. data/icons/siberas_logo_x24.gif +0 -0
  92. data/icons/tag_blue_32x32.ico +0 -0
  93. data/icons/watobo-48x48.png +0 -0
  94. data/icons/watobo-logo.png +0 -0
  95. data/icons/watobo.ico +0 -0
  96. data/lib/watobo/adapters/data_store.rb +38 -0
  97. data/lib/watobo/adapters/file/file_store.rb +211 -0
  98. data/lib/watobo/adapters/session_store.rb +27 -0
  99. data/lib/watobo/adapters.rb +26 -0
  100. data/lib/watobo/config.rb +143 -0
  101. data/lib/watobo/constants.rb +92 -0
  102. data/lib/watobo/core/active_check.rb +404 -0
  103. data/lib/watobo/core/cookie.rb +69 -0
  104. data/lib/watobo/core/fuzz_gen.rb +160 -0
  105. data/lib/watobo/core/http_socket.rb +142 -0
  106. data/lib/watobo/core/interceptor.rb +729 -0
  107. data/lib/watobo/core/passive_check.rb +141 -0
  108. data/lib/watobo/core/project.rb +1058 -0
  109. data/lib/watobo/core/scanner.rb +396 -0
  110. data/lib/watobo/core/session.rb +1320 -0
  111. data/lib/watobo/core/simple_ca.rb +393 -0
  112. data/lib/watobo/core.rb +34 -0
  113. data/lib/watobo/defaults.rb +40 -0
  114. data/lib/watobo/external/diff/lcs/array.rb +42 -0
  115. data/lib/watobo/external/diff/lcs/block.rb +72 -0
  116. data/lib/watobo/external/diff/lcs/callbacks.rb +343 -0
  117. data/lib/watobo/external/diff/lcs/change.rb +190 -0
  118. data/lib/watobo/external/diff/lcs/hunk.rb +279 -0
  119. data/lib/watobo/external/diff/lcs/ldiff.rb +247 -0
  120. data/lib/watobo/external/diff/lcs/string.rb +40 -0
  121. data/lib/watobo/external/diff/lcs.rb +1124 -0
  122. data/lib/watobo/external/ntlm/ntlm.rb +797 -0
  123. data/lib/watobo/externals.rb +28 -0
  124. data/lib/watobo/framework/create_project.rb +55 -0
  125. data/lib/watobo/framework/init.rb +149 -0
  126. data/lib/watobo/framework/init_modules.rb +116 -0
  127. data/lib/watobo/framework/license_text.rb +50 -0
  128. data/lib/watobo/framework.rb +26 -0
  129. data/lib/watobo/gui/about_watobo.rb +68 -0
  130. data/lib/watobo/gui/browser_preview.rb +460 -0
  131. data/lib/watobo/gui/certificate_dialog.rb +132 -0
  132. data/lib/watobo/gui/chat_diff.rb +415 -0
  133. data/lib/watobo/gui/chatviewer_frame.rb +427 -0
  134. data/lib/watobo/gui/checkboxtree.rb +221 -0
  135. data/lib/watobo/gui/checks_policy_frame.rb +123 -0
  136. data/lib/watobo/gui/client_cert_dialog.rb +227 -0
  137. data/lib/watobo/gui/confirm_scan_dialog.rb +67 -0
  138. data/lib/watobo/gui/conversation_table.rb +386 -0
  139. data/lib/watobo/gui/conversation_table_ctrl.rb +175 -0
  140. data/lib/watobo/gui/csrf_token_dialog.rb +446 -0
  141. data/lib/watobo/gui/dashboard.rb +341 -0
  142. data/lib/watobo/gui/define_scope_frame.rb +380 -0
  143. data/lib/watobo/gui/edit_comment.rb +70 -0
  144. data/lib/watobo/gui/edit_scope_dialog.rb +69 -0
  145. data/lib/watobo/gui/finding_info.rb +212 -0
  146. data/lib/watobo/gui/findings_tree.rb +459 -0
  147. data/lib/watobo/gui/full_scan_dialog.rb +269 -0
  148. data/lib/watobo/gui/fuzzer_gui.rb +1522 -0
  149. data/lib/watobo/gui/hex_viewer.rb +106 -0
  150. data/lib/watobo/gui/interceptor_gui.rb +994 -0
  151. data/lib/watobo/gui/interceptor_settings_dialog.rb +201 -0
  152. data/lib/watobo/gui/log_viewer.rb +97 -0
  153. data/lib/watobo/gui/login_wizzard.rb +301 -0
  154. data/lib/watobo/gui/main_window.rb +1815 -0
  155. data/lib/watobo/gui/manual_request_editor.rb +1105 -0
  156. data/lib/watobo/gui/master_pw_dialog.rb +142 -0
  157. data/lib/watobo/gui/password_policy_dialog.rb +98 -0
  158. data/lib/watobo/gui/plugin/base.rb +82 -0
  159. data/lib/watobo/gui/plugin_board.rb +95 -0
  160. data/lib/watobo/gui/preferences_dialog.rb +116 -0
  161. data/lib/watobo/gui/progress_window.rb +102 -0
  162. data/lib/watobo/gui/project_wizzard.rb +369 -0
  163. data/lib/watobo/gui/proxy_dialog.rb +550 -0
  164. data/lib/watobo/gui/quick_scan_dialog.rb +242 -0
  165. data/lib/watobo/gui/request_editor.rb +480 -0
  166. data/lib/watobo/gui/save_chat_dialog.rb +158 -0
  167. data/lib/watobo/gui/scanner_settings_dialog.rb +360 -0
  168. data/lib/watobo/gui/select_chat_dialog.rb +169 -0
  169. data/lib/watobo/gui/session_management_dialog.rb +688 -0
  170. data/lib/watobo/gui/sites_tree.rb +347 -0
  171. data/lib/watobo/gui/status_bar.rb +88 -0
  172. data/lib/watobo/gui/table_editor.rb +445 -0
  173. data/lib/watobo/gui/tagless_viewer.rb +62 -0
  174. data/lib/watobo/gui/templates/plugin.rb +80 -0
  175. data/lib/watobo/gui/templates/plugin2.rb +103 -0
  176. data/lib/watobo/gui/text_viewer.rb +247 -0
  177. data/lib/watobo/gui/transcoder_window.rb +215 -0
  178. data/lib/watobo/gui/utils/gui_utils.rb +129 -0
  179. data/lib/watobo/gui/utils/init_icons.rb +106 -0
  180. data/lib/watobo/gui/utils/load_icons.rb +54 -0
  181. data/lib/watobo/gui/utils/load_plugins.rb +94 -0
  182. data/lib/watobo/gui/utils/master_password.rb +90 -0
  183. data/lib/watobo/gui/utils/save_default_settings.rb +99 -0
  184. data/lib/watobo/gui/utils/save_project_settings.rb +21 -0
  185. data/lib/watobo/gui/utils/save_proxy_settings.rb +45 -0
  186. data/lib/watobo/gui/utils/save_session_settings.rb +21 -0
  187. data/lib/watobo/gui/utils/session_history.rb +134 -0
  188. data/lib/watobo/gui/workspace_dialog.rb +89 -0
  189. data/lib/watobo/gui/www_auth_dialog.rb +348 -0
  190. data/lib/watobo/gui/xml_viewer_frame.rb +114 -0
  191. data/lib/watobo/gui.rb +139 -0
  192. data/lib/watobo/mixins/httpparser.rb +664 -0
  193. data/lib/watobo/mixins/request_parser.rb +210 -0
  194. data/lib/watobo/mixins/shapers.rb +345 -0
  195. data/lib/watobo/mixins/transcoders.rb +88 -0
  196. data/lib/watobo/mixins.rb +32 -0
  197. data/lib/watobo/utils/check_regex.rb +36 -0
  198. data/lib/watobo/utils/copy_object.rb +29 -0
  199. data/lib/watobo/utils/crypto.rb +74 -0
  200. data/lib/watobo/utils/expand_range.rb +45 -0
  201. data/lib/watobo/utils/file_management.rb +73 -0
  202. data/lib/watobo/utils/load_chat.rb +219 -0
  203. data/lib/watobo/utils/load_icon.rb +47 -0
  204. data/lib/watobo/utils/print_debug.rb +34 -0
  205. data/lib/watobo/utils/response_hash.rb +143 -0
  206. data/lib/watobo/utils/secure_eval.rb +57 -0
  207. data/lib/watobo/utils/text2request.rb +96 -0
  208. data/lib/watobo/utils.rb +32 -0
  209. data/lib/watobo.rb +76 -0
  210. data/modules/active/Apache/mod_status.rb +123 -0
  211. data/modules/active/Flash/crossdomain.rb +102 -0
  212. data/modules/active/directories/dirwalker.rb +89 -0
  213. data/modules/active/discovery/fileextensions.rb +151 -0
  214. data/modules/active/discovery/http_methods.rb +135 -0
  215. data/modules/active/domino/domino_db.lst +164 -0
  216. data/modules/active/domino/domino_db.rb +128 -0
  217. data/modules/active/fileinclusion/lfi_simple.rb +134 -0
  218. data/modules/active/jboss/jboss_basic.rb +119 -0
  219. data/modules/active/sap/business_objects.rb +73 -0
  220. data/modules/active/sap/its_commands.rb +101 -0
  221. data/modules/active/sap/its_service_parameter.rb +105 -0
  222. data/modules/active/sap/its_services.rb +103 -0
  223. data/modules/active/sap/its_xss.rb +98 -0
  224. data/modules/active/sqlinjection/sql_boolean.rb +262 -0
  225. data/modules/active/sqlinjection/sqli_simple.rb +205 -0
  226. data/modules/active/xss/xss_simple.rb +179 -0
  227. data/modules/passive/cookie_options.rb +97 -0
  228. data/modules/passive/cookie_xss.rb +85 -0
  229. data/modules/passive/detect_code.rb +89 -0
  230. data/modules/passive/detect_fileupload.rb +80 -0
  231. data/modules/passive/detect_infrastructure.rb +98 -0
  232. data/modules/passive/detect_one_time_tokens.rb +86 -0
  233. data/modules/passive/dirindexing.rb +81 -0
  234. data/modules/passive/disclosure_emails.rb +82 -0
  235. data/modules/passive/disclosure_ipaddr.rb +87 -0
  236. data/modules/passive/filename_as_parameter.rb +85 -0
  237. data/modules/passive/form_spotter.rb +75 -0
  238. data/modules/passive/hotspots.rb +86 -0
  239. data/modules/passive/in_script_parameter.rb +92 -0
  240. data/modules/passive/multiple_server_headers.rb +98 -0
  241. data/modules/passive/possible_login.rb +134 -0
  242. data/modules/passive/redirect_url.rb +88 -0
  243. data/modules/passive/redirectionz.rb +96 -0
  244. data/modules/passive/xss_dom.rb +91 -0
  245. data/plugins/catalog/catalog.ico +0 -0
  246. data/plugins/catalog/catalog.rb +726 -0
  247. data/plugins/catalog/db_tests +6483 -0
  248. data/plugins/catalog/db_variables +29 -0
  249. data/plugins/filefinder/dbs/hbci.db +12 -0
  250. data/plugins/filefinder/filefinder.rb +602 -0
  251. data/plugins/sslchecker/cli/sslchecker_cli.rb +21 -0
  252. data/plugins/sslchecker/gui/cipher_table.rb +260 -0
  253. data/plugins/sslchecker/gui/gui.rb +245 -0
  254. data/plugins/sslchecker/gui/sslchecker.rb +26 -0
  255. data/plugins/sslchecker/icons/green_16x16.ico +0 -0
  256. data/plugins/sslchecker/icons/grey_16x16.ico +0 -0
  257. data/plugins/sslchecker/icons/red_16x16.ico +0 -0
  258. data/plugins/sslchecker/icons/sslchecker.ico +0 -0
  259. data/plugins/sslchecker/lib/check.rb +117 -0
  260. metadata +317 -0
@@ -0,0 +1,427 @@
1
+ # .
2
+ # chatviewer_frame.rb
3
+ #
4
+ # Copyright 2012 by siberas, http://www.siberas.de
5
+ #
6
+ # This file is part of WATOBO (Web Application Tool Box)
7
+ # http://watobo.sourceforge.com
8
+ #
9
+ # WATOBO is free software; you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation version 2 of the License.
12
+ #
13
+ # WATOBO is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with WATOBO; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ # .
22
+ module Watobo
23
+ module Gui
24
+
25
+ SEL_TYPE_GREP = 0
26
+ SEL_TYPE_HIGHLIGHT = 1
27
+ class TextViewer < FXVerticalFrame
28
+
29
+ attr_accessor :max_len
30
+ def style=(new_style)
31
+ @simple_text_view.style = new_style
32
+ end
33
+
34
+ def editable=(value)
35
+ @simple_text_view.editable = value
36
+ end
37
+
38
+ def setText(text, prefs={})
39
+ @text = text
40
+ @simple_text_view.max_len = @max_len
41
+ @simple_text_view.setText(text, prefs)
42
+ @match_pos_label.text = "0/0"
43
+ @match_pos_label.textColor = 'grey'
44
+
45
+ applyFilter() if @auto_apply_cbtn.checked?
46
+ end
47
+
48
+ def highlight(pattern)
49
+ highlightPattern(pattern)
50
+ end
51
+
52
+ def setFont(font_type=nil, size=nil)
53
+ @simple_text_view.setFont(font_type, size)
54
+ end
55
+
56
+ def getText
57
+ @simple_text_view.textbox.to_s
58
+ end
59
+
60
+ def initialize(owner, opts)
61
+ super(owner, opts)
62
+
63
+ @text_matches = []
64
+
65
+ @style = 2 # default style
66
+ @text = ''
67
+ @max_len = 5000
68
+ @filter_mode = SEL_TYPE_HIGHLIGHT
69
+ @cur_match_pos = 0
70
+ @text_dt = FXDataTarget.new('')
71
+ @filter_dt = FXDataTarget.new('')
72
+
73
+ text_view_header = FXHorizontalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_SIDE_BOTTOM|LAYOUT_FIX_HEIGHT,:height => 24, :padding => 0)
74
+
75
+ #@auto_apply_cbtn.connect(SEL_COMMAND, method(:onInterceptChanged))
76
+
77
+ pmatch_btn = FXButton.new(text_view_header, "<", nil, nil, 0, FRAME_RAISED|LAYOUT_FILL_Y)
78
+ @match_pos_label = FXLabel.new(text_view_header, "0/0", :opts => LAYOUT_FILL_Y)
79
+ @match_pos_label.textColor = 'grey'
80
+ pmatch_btn.connect(SEL_COMMAND) { gotoPrevMatch() }
81
+ nmatch_btn = FXButton.new(text_view_header, ">", nil, nil, 0, FRAME_RAISED|LAYOUT_FILL_Y)
82
+ nmatch_btn.connect(SEL_COMMAND) { gotoNextMatch() }
83
+
84
+ # @filter_text = FXTextField.new(text_view_header, 10,
85
+ # :target => @filter_dt, :selector => FXDataTarget::ID_VALUE,
86
+ # :opts => FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y)
87
+
88
+ @filter_text = FXComboBox.new(text_view_header, 20, @filter_dt, 0, FRAME_SUNKEN|FRAME_THICK|LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
89
+ @filter_text.connect(SEL_COMMAND){
90
+ applyFilter()
91
+ addFilterHistory()
92
+ }
93
+
94
+ @filter_text.connect(SEL_CHANGED) {
95
+ applyFilter()
96
+ }
97
+
98
+ menu = FXMenuPane.new(self)
99
+ FXMenuCommand.new(menu, "&Highlight").connect(SEL_COMMAND){
100
+ @filter_mode = SEL_TYPE_HIGHLIGHT
101
+ applyFilter()
102
+ @mode_btn.text = "Highlight"
103
+ }#, method(:switchMethod))
104
+ FXMenuCommand.new(menu, "&Grep").connect(SEL_COMMAND){
105
+ @filter_mode = SEL_TYPE_GREP
106
+ applyFilter()
107
+ @mode_btn.text = "Grep"
108
+ }#, method(:switchMethod))
109
+
110
+ @auto_apply_cbtn = FXCheckButton.new(text_view_header, "auto-apply", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP|LAYOUT_RIGHT|LAYOUT_FILL_Y)
111
+ @mode_btn = FXMenuButton.new(text_view_header, "Highlight", nil, menu,
112
+ :opts=> MENUBUTTON_DOWN|FRAME_RAISED|FRAME_THICK|ICON_AFTER_TEXT|LAYOUT_RIGHT|LAYOUT_FILL_Y)
113
+
114
+ reset_button = FXButton.new(text_view_header, "&Reset", nil, nil, 0, FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_Y)
115
+ reset_button.connect(SEL_COMMAND){ resetFilter() }
116
+
117
+ text_box_frame = FXVerticalFrame.new(self, LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding => 0)
118
+
119
+ @simple_text_view = SimpleTextView.new(text_box_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y,:padding => 0)
120
+ @simple_text_view.style = 1
121
+ @simple_text_view.editable = false
122
+ @simple_text_view.textStyle -= TEXT_WORDWRAP
123
+
124
+ addHotkeyHandler(@simple_text_view.textbox)
125
+ addHotkeyHandler(@filter_text)
126
+
127
+ @filter_dt.connect(SEL_COMMAND) { applyFilter() }
128
+
129
+ end
130
+
131
+ def applyFilter
132
+ pattern = @filter_text.text
133
+ @match_pos_label.text = "0/0"
134
+ @simple_text_view.resetMatches()
135
+ @simple_text_view.setText(@text)
136
+ @match_pos_label.textColor = 'grey'
137
+ return true if pattern == ''
138
+ case @filter_mode
139
+ when SEL_TYPE_GREP
140
+ grepPattern(pattern)
141
+ when SEL_TYPE_HIGHLIGHT
142
+ highlightPattern(pattern)
143
+ end
144
+ end
145
+
146
+ private
147
+
148
+ def gotoNextMatch()
149
+ @cur_match_pos += 1 if @cur_match_pos < @simple_text_view.numMatches-1
150
+ @simple_text_view.makeMatchVisible(@cur_match_pos)
151
+ @match_pos_label.text = "#{@cur_match_pos+1}/#{@simple_text_view.numMatches}" if @simple_text_view.numMatches > 0
152
+ end
153
+
154
+ def gotoPrevMatch()
155
+ @cur_match_pos -= 1 if @cur_match_pos > 0
156
+ @simple_text_view.makeMatchVisible(@cur_match_pos)
157
+ @match_pos_label.text = "#{@cur_match_pos+1}/#{@simple_text_view.numMatches}" if @simple_text_view.numMatches > 0
158
+ end
159
+
160
+ def addFilterHistory()
161
+ text = @filter_text.text
162
+ return true if text == ''
163
+ has_item = false
164
+ @filter_text.each do |item, data|
165
+ has_item = true if data == text
166
+ end
167
+ @filter_text.appendItem(text, text) unless has_item == true
168
+ @filter_text.numVisible = @filter_text.numItems
169
+ end
170
+
171
+ def resetFilter
172
+ @simple_text_view.max_len = 0
173
+ @simple_text_view.setText(@text)
174
+ @match_pos_label.text = "0/0"
175
+ @match_pos_label.textColor = 'grey'
176
+ @filter_text.text = ''
177
+ end
178
+
179
+ def highlightPattern(pattern)
180
+ @cur_match_pos = 0
181
+ @simple_text_view.max_len = 0
182
+
183
+ @match_pos_label.textColor = 'black'
184
+
185
+ @simple_text_view.setText(@text)
186
+ @simple_text_view.highlight(pattern)
187
+ @match_pos_label.text = "0/#{@simple_text_view.numMatches()}"
188
+
189
+ @simple_text_view.makeMatchVisible(0)
190
+
191
+ @match_pos_label.text = "1/#{@simple_text_view.numMatches()}" if @simple_text_view.numMatches() > 0
192
+
193
+ end
194
+
195
+ def grepPattern(pattern)
196
+ @cur_match_pos = 0
197
+ @simple_text_view.max_len = 0
198
+
199
+ @match_pos_label.textColor = 'black'
200
+
201
+ @simple_text_view.setText(@text)
202
+
203
+ @simple_text_view.filter(pattern)
204
+ @match_pos_label.text = "0/#{@simple_text_view.numMatches()}"
205
+ @simple_text_view.highlight(pattern)
206
+ @simple_text_view.makeMatchVisible(0)
207
+
208
+ @filter_mode = SEL_TYPE_GREP
209
+
210
+ @match_pos_label.text = "1/#{@simple_text_view.numMatches()}" if @simple_text_view.numMatches() > 0
211
+
212
+ end
213
+
214
+ def addHotkeyHandler(widget)
215
+ @ctrl_pressed = false
216
+
217
+ widget.connect(SEL_KEYPRESS) { |sender, sel, event|
218
+ # puts event.code
219
+ @ctrl_pressed = true if event.code == KEY_Control_L or event.code == KEY_Control_R
220
+ # @shift_pressed = true if @ctrl_pressed and ( event.code == KEY_Shift_L or event.code == KEY_Shift_R )
221
+ if event.code == KEY_Return
222
+ highlight(@filter_text.text)
223
+ true # special handling of KEY_Return, because we don't want a linebreak in textbox.
224
+ end
225
+
226
+ if event.code == KEY_F1
227
+
228
+ unless event.moved?
229
+ FXMenuPane.new(self) do |menu_pane|
230
+ FXMenuCaption.new(menu_pane, "Hotkeys:")
231
+ FXMenuSeparator.new(menu_pane)
232
+ [ "<ctrl-r> - Reset Filter",
233
+ "<ctrl-g> - Grep",
234
+ "<ctrl-h> - Highlight",
235
+ "<ctrl-n> - Goto Next",
236
+ "<ctrl-shift-n> - Goto Prev",
237
+ "<ctrl-w> - Switch Wordwrap"
238
+ ].each do |hk|
239
+ FXMenuCaption.new(menu_pane, hk).backColor = 'yellow'
240
+ end
241
+
242
+ menu_pane.create
243
+ menu_pane.popup(nil, event.root_x, event.root_y)
244
+ app.runModalWhileShown(menu_pane)
245
+ end
246
+
247
+ end
248
+ end
249
+
250
+ if @ctrl_pressed
251
+ case event.code
252
+ when KEY_n
253
+ gotoNextMatch()
254
+ addFilterHistory()
255
+ when KEY_N
256
+ gotoPrevMatch()
257
+ addFilterHistory()
258
+ when KEY_w
259
+ @simple_text_view.textbox.textStyle ^= TEXT_WORDWRAP
260
+ when KEY_h
261
+ @mode_btn.text = "Highlight"
262
+ @filter_mode = SEL_TYPE_HIGHLIGHT
263
+ addFilterHistory()
264
+ applyFilter()
265
+ when KEY_g
266
+ @mode_btn.text = "Grep"
267
+ @filter_mode = SEL_TYPE_GREP
268
+ addFilterHistory()
269
+ applyFilter()
270
+ when KEY_r
271
+ resetFilter()
272
+
273
+ end
274
+ end
275
+ false
276
+ }
277
+
278
+ widget.connect(SEL_KEYRELEASE) { |sender, sel, event|
279
+ @ctrl_pressed = false if event.code == KEY_Control_L or event.code == KEY_Control_R
280
+ false
281
+ }
282
+ end
283
+
284
+ end
285
+
286
+ class RequestViewer < FXVerticalFrame
287
+
288
+ attr_accessor :max_len
289
+ def setText(text)
290
+ @text = text
291
+ @textviewer.max_len = @max_len
292
+ index = @tabBook.current
293
+ @viewers[index].setText(text)
294
+ end
295
+
296
+ def setFontSize(size)
297
+ @textviewer.setFont(nil, size)
298
+ end
299
+
300
+ def getText
301
+ index = @tabBook.current
302
+ @viewers[index].getText()
303
+ end
304
+
305
+ def highlight(pattern)
306
+ begin
307
+ index = @tabBook.current
308
+ @viewers[index].highlight(pattern)
309
+ rescue
310
+ end
311
+ end
312
+
313
+ def initialize(owner, opts)
314
+ super(owner, opts)
315
+ @tabbook = nil
316
+ @viewers = []
317
+ @text = ''
318
+ @max_len = 5000
319
+
320
+ @tabBook = FXTabBook.new(self, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_RIGHT)
321
+ @tabBook.connect(SEL_COMMAND) {
322
+ begin
323
+ getApp().beginWaitCursor()
324
+ setText(@text)
325
+ ensure
326
+ getApp().endWaitCursor()
327
+ end
328
+ }
329
+ textviewer_tab = FXTabItem.new(@tabBook, "Text", nil)
330
+ tab_frame = FXVerticalFrame.new(@tabBook, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED)
331
+ @textviewer = TextViewer.new(tab_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y,:padding => 0)
332
+ @textviewer.style = 1
333
+ @textviewer.editable = false
334
+
335
+ @viewers.push @textviewer
336
+
337
+ FXTabItem.new(@tabBook, "Hex", nil)
338
+ tab_frame = FXVerticalFrame.new(@tabBook, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED)
339
+ @hexViewer = HexViewer.new(tab_frame)
340
+ @viewers.push @hexViewer
341
+ end
342
+
343
+ end
344
+
345
+ class ResponseViewer < FXVerticalFrame
346
+
347
+ include Watobo::Gui::Utils
348
+
349
+ attr_accessor :max_len, :auto_filter
350
+ def setText(text, prefs={})
351
+
352
+ @text = text
353
+ @textviewer.max_len = @max_len
354
+ index = @tabBook.current
355
+
356
+ @viewers[index].setText(text)
357
+ # @textviewer.applyFilter if cp[:filter] == true
358
+
359
+ end
360
+
361
+ def setFontSize(size)
362
+ @textviewer.setFont(nil, size)
363
+ end
364
+
365
+ def getText
366
+ index = @tabBook.current
367
+ @viewers[index].getText()
368
+ end
369
+
370
+ def highlight(pattern)
371
+ begin
372
+ index = @tabBook.current
373
+ @viewers[index].highlight(pattern)
374
+ rescue
375
+ end
376
+ end
377
+
378
+ def initialize(owner, opts)
379
+ super(owner, opts)
380
+
381
+ @tabbook = nil
382
+ @viewers = []
383
+ @text = ''
384
+ @max_len = 5000
385
+
386
+ @auto_filter = false
387
+
388
+ @tabBook = FXTabBook.new(self, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_RIGHT)
389
+ @tabBook.connect(SEL_COMMAND) {
390
+ begin
391
+ getApp().beginWaitCursor()
392
+ setText(@text)
393
+ ensure
394
+ getApp().endWaitCursor()
395
+ end
396
+ }
397
+
398
+ @text_dt = FXDataTarget.new('')
399
+
400
+ textviewer_tab = FXTabItem.new(@tabBook, "Text", nil)
401
+ tab_frame = FXVerticalFrame.new(@tabBook, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED)
402
+ @textviewer = TextViewer.new( tab_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
403
+
404
+ @textviewer.style = 2
405
+ @textviewer.editable = false
406
+ # @textviewer.target = @text_dt
407
+ # @textviewer.selector = FXDataTarget::ID_VALUE
408
+
409
+ @viewers << @textviewer
410
+
411
+ taglessviewer_tab = FXTabItem.new(@tabBook, "Tagless", nil)
412
+ tab_frame = FXVerticalFrame.new(@tabBook, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED)
413
+ tagless_frame = FXVerticalFrame.new(tab_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding=>0)
414
+ #text_view_header = FXHorizontalFrame.new(tagless_frame, :opts => LAYOUT_FILL_X|LAYOUT_SIDE_BOTTOM)
415
+ @taglessviewer = TaglessViewer.new(tagless_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
416
+ @viewers << @taglessviewer
417
+
418
+ FXTabItem.new(@tabBook, "Hex", nil)
419
+ tab_frame = FXVerticalFrame.new(@tabBook, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED)
420
+ @hexViewer = HexViewer.new(tab_frame)
421
+ @viewers << @hexViewer
422
+ end
423
+
424
+ end
425
+ ###################### end of namespace ############################
426
+ end
427
+ end
@@ -0,0 +1,221 @@
1
+ # .
2
+ # checkboxtree.rb
3
+ #
4
+ # Copyright 2012 by siberas, http://www.siberas.de
5
+ #
6
+ # This file is part of WATOBO (Web Application Tool Box)
7
+ # http://watobo.sourceforge.com
8
+ #
9
+ # WATOBO is free software; you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation version 2 of the License.
12
+ #
13
+ # WATOBO is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with WATOBO; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ # .
22
+ module Watobo
23
+ module Gui
24
+ class CheckBoxTreeItem < FXTreeItem
25
+ attr_accessor :checked
26
+
27
+ include Watobo::Gui::Icons
28
+ def initialize(text, checked, data)
29
+ @checked = checked
30
+ icon = ICON_CB_CHECKED
31
+ icon = ICON_CB_UNCHECKED if not checked
32
+ super(text, icon, icon, data)
33
+ end
34
+ end
35
+
36
+ class CheckBoxTreeList < FXTreeList
37
+ include Watobo::Gui::Icons
38
+ #------------------------------
39
+ # C R E A T E T R E E
40
+ #------------------------------
41
+ # elements[] = [{
42
+ # :name => element_name, number of subtrees controlled via pipe-char, e.g. <level1>|<level2>|item
43
+ # :enabled => true|false,
44
+ # :data => object|string|...
45
+ # }, {..} ]
46
+ def createTree(elements)
47
+ self.clearItems()
48
+ elements.each do |e|
49
+
50
+ # puts icon.class.to_s
51
+ node = nil
52
+ levels = e[:name].split('|')
53
+ # puts "Processing: #{e[:name]}"
54
+ levels.each do |l|
55
+
56
+ item = self.findItem(l, node, SEARCH_FORWARD|SEARCH_IGNORECASE)
57
+
58
+ if item.nil? then
59
+ new_item = CheckBoxTreeItem.new(l, e[:enabled], nil)
60
+ # item = self.appendItem(node, l, ICON_CB_CHECKED, ICON_CB_CHECKED)
61
+ item = self.appendItem(node, new_item)
62
+ if e[:enabled] then
63
+ self.openItem(item, false)
64
+ else
65
+ self.closeItem(item, false)
66
+ end
67
+ end
68
+ node = item
69
+ if l == levels.last then
70
+ self.setItemData(item, e[:data])
71
+ updateParent(item)
72
+ end
73
+
74
+ end
75
+ end
76
+ end
77
+
78
+ def updateParent(child)
79
+ parent = child.parent
80
+ # count enabled childs
81
+ return false if parent.nil?
82
+ ec = 0
83
+ parent.each do |item|
84
+ #data = self.getItemData(item)
85
+ #ec += 1 if data[:enabled]
86
+ ec += 1 if item.checked
87
+ end
88
+ if ec == 0 then
89
+
90
+ # puts "no childs selected"
91
+ icon = ICON_CB_UNCHECKED
92
+ self.setItemData(parent, :none)
93
+ elsif ec < parent.numChildren then
94
+ # puts "not all childs are selected"
95
+ icon = ICON_CB_CHECKED_ORANGE
96
+ self.setItemData(parent, :partly)
97
+ else
98
+
99
+ # puts "all childs have been selected"
100
+ icon = ICON_CB_CHECKED
101
+ self.setItemData(parent, :all)
102
+ end
103
+ self.setItemOpenIcon(parent, icon)
104
+ self.setItemClosedIcon(parent, icon)
105
+ end
106
+
107
+ def toggleState(item)
108
+ # data = self.getItemData(item)
109
+ # if data[:enabled] then
110
+ if item.checked then
111
+ uncheckItem(item)
112
+ else
113
+ checkItem(item)
114
+ end
115
+ end
116
+
117
+ def uncheckItem(item)
118
+ begin
119
+ #data = self.getItemData(item)
120
+ #data[:enabled]= false
121
+ item.checked = false
122
+ self.setItemOpenIcon(item, ICON_CB_UNCHECKED)
123
+ self.setItemClosedIcon(item, ICON_CB_UNCHECKED)
124
+ #puts item.data.class
125
+ rescue => bang
126
+ puts "!!!ERROR: could not uncheck item"
127
+ end
128
+
129
+ end
130
+
131
+
132
+ def getCheckedData(item = nil, data = nil)
133
+ data = [] if !data
134
+ item = self if !item
135
+ item.each do |c|
136
+ getCheckedData(c, data) if c.numChildren > 0
137
+ data.push c.data if self.itemLeaf?(c) and c.checked
138
+ end
139
+ data
140
+ end
141
+
142
+ def checkItem(item)
143
+ begin
144
+ #data = self.getItemData(item)
145
+ #data[:enabled] = true
146
+ item.checked = true
147
+ self.setItemClosedIcon(item, ICON_CB_CHECKED)
148
+ self.setItemOpenIcon(item, ICON_CB_CHECKED)
149
+ # puts item.data.class
150
+ rescue => bang
151
+ puts "!!!ERROR: could not uncheck item"
152
+ end
153
+ end
154
+
155
+ def uncheckAllChildren(parent)
156
+ parent.each do |child|
157
+ uncheckItem(child)
158
+ end
159
+ end
160
+
161
+ def checkAllChildren(parent)
162
+ parent.each do |child|
163
+ checkItem(child)
164
+ end
165
+ end
166
+
167
+ def initialize(parent)
168
+
169
+ @parent = parent
170
+ super(parent, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|
171
+ TREELIST_SHOWS_LINES|
172
+ TREELIST_SHOWS_BOXES|
173
+ TREELIST_ROOT_BOXES|
174
+ #TREELIST_EXTENDEDSELECT|
175
+ TREELIST_MULTIPLESELECT
176
+ )
177
+ #LAYOUT_TOP|LAYOUT_RIGHT|TREELIST_SHOWS_LINES|TREELIST_SHOWS_BOXES|TREELIST_ROOT_BOXES|TREELIST_EXTENDEDSELECT
178
+
179
+ self.connect(SEL_COMMAND) do |sender, sel, item|
180
+ # puts "Selected Item: #{item}"
181
+ # if item.parent
182
+ # puts "Member Of: #{item.parent}"
183
+ # puts "Has Brothers: #{item.parent.numChildren}"
184
+ # end
185
+ if self.itemLeaf?(item) then
186
+ toggleState(item)
187
+ updateParent(item)
188
+ else
189
+ data = self.getItemData(item)
190
+ new_state = case data
191
+ when :partly
192
+ # puts data
193
+ icon = ICON_CB_UNCHECKED
194
+ uncheckAllChildren(item)
195
+ :none
196
+ when :none
197
+ # puts data
198
+ icon = ICON_CB_CHECKED
199
+ checkAllChildren(item)
200
+ :all
201
+ when :all
202
+ # puts data
203
+ icon = ICON_CB_UNCHECKED
204
+ uncheckAllChildren(item)
205
+ :none
206
+ end
207
+ self.setItemData(item, new_state)
208
+ self.setItemClosedIcon(item, icon)
209
+ self.setItemOpenIcon(item, icon)
210
+ end
211
+
212
+ self.killSelection()
213
+ end
214
+
215
+
216
+
217
+ end
218
+ end
219
+ #--
220
+ end
221
+ end