Class: Watobo::Gui::QuickScanOptionsFrame

Inherits:
FXVerticalFrame
  • Object
show all
Defined in:
lib/watobo/gui/quick_scan_dialog.rb

Instance Method Summary collapse

Constructor Details

#initialize(owner, prefs = {}) ⇒ QuickScanOptionsFrame

Returns a new instance of QuickScanOptionsFrame.


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/watobo/gui/quick_scan_dialog.rb', line 43

def initialize(owner, prefs = {} )

  super(owner, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)

  @csrf_ids = []
  @csrf_patterns = []
  @target_chat = prefs[:target_chat]

  # scan_opt_frame= FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
  @useOriginalRequest = FXCheckButton.new(self, "Use original request", nil, 0, JUSTIFY_LEFT|JUSTIFY_TOP|ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP)
  @useOriginalRequest.checkState = true
  
  @followRedirects = FXCheckButton.new(self, "Follow redirects", nil, 0, JUSTIFY_LEFT|JUSTIFY_TOP|ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP)
  @followRedirects.checkState = false
  
  @detectLogout = FXCheckButton.new(self, "Autom. login when logged out", nil, 0, JUSTIFY_LEFT|JUSTIFY_TOP|ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP)
  @detectLogout.checkState = false

  frame = FXGroupBox.new(self, "Logging", LAYOUT_SIDE_TOP|FRAME_GROOVE|LAYOUT_FILL_X, 0, 0, 0, 0)
  @logScanChats = FXCheckButton.new(frame, "Log Scan", nil, 0, JUSTIFY_LEFT|JUSTIFY_TOP|ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP)
  @logScanChats.checkState = false
  @logScanChats.connect(SEL_COMMAND) do |sender, sel, item|
    if @logScanChats.checked? then
      @scanlog_name_text.enabled = true
      @scanlog_dir_label.enabled = true
    #  @scanlog_dir_btn.enable
    else
      @scanlog_name_text.enabled = false
      @scanlog_dir_label.enabled = false
     # @scanlog_dir_btn.disable
    end
  end

  @scanlog_name_dt = FXDataTarget.new('')
 # @scanlog_name_dt.value = @project.scanLogDirectory() if File.exist?(@project.scanLogDirectory())
  @scanlog_dir_label = FXLabel.new(frame, "Scan-Name:" )
  scanlog_frame = FXHorizontalFrame.new(frame,:opts => LAYOUT_FILL_X|LAYOUT_SIDE_TOP)
  @scanlog_name_text = FXTextField.new(scanlog_frame, 20,
  :target => @scanlog_name_dt, :selector => FXDataTarget::ID_VALUE,
  :opts => TEXTFIELD_NORMAL|LAYOUT_FILL_COLUMN|LAYOUT_FILL_X)
  @scanlog_name_text.handle(self, FXSEL(SEL_UPDATE, 0), nil)
 # @scanlog_dir_btn = FXButton.new(scanlog_frame, "Change")
 # @scanlog_dir_btn.connect(SEL_COMMAND, method(:selectScanlogDirectory))

  @scanlog_name_text.enabled = false
  @scanlog_dir_label.enabled = false
#  @scanlog_dir_btn.disable

  frame = FXGroupBox.new(self, "One-Time-Token Settings", LAYOUT_SIDE_TOP|FRAME_GROOVE|LAYOUT_FILL_X, 0, 0, 0, 0)
  csrf_frame = FXHorizontalFrame.new(frame,:opts => LAYOUT_FILL_X|LAYOUT_SIDE_TOP, :padding => 0)
  @csrfToken = FXCheckButton.new(csrf_frame, "Update One-Time-Tokens", nil, 0, JUSTIFY_LEFT|JUSTIFY_TOP|ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP)
  #@csrfToken.checkState = false
  @csrfToken.checkState = prefs.has_key?(:enable_one_time_tokens) ? prefs[:enable_one_time_tokens] : false

  @csrfToken.connect(SEL_COMMAND) do |sender, sel, item|
    if @csrfToken.checked? then
      @csrf_dialog_btn.enable
    else
      @csrf_dialog_btn.disable
    end
  end

  @csrf_dialog_btn = FXButton.new(csrf_frame, "O-T-T Settings")
  @csrf_dialog_btn.connect(SEL_COMMAND, method(:openCSRFTokenDialog))

  #  @csrf_dialog_text.enabled = false
  #  @csrf_dialog_label.enabled = false
  @csrf_dialog_btn.disable
  @csrf_dialog_btn.enable if @csrfToken.checked?
end

Instance Method Details

#optionsObject


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/watobo/gui/quick_scan_dialog.rb', line 26

def options()
  csrf_requests = Watobo::OTTCache.requests(@target_chat)
  
  o = Hash.new
  o[:enable_logging] = @logScanChats.checked?
  o[:scanlog_name] = @scanlog_name_dt.value
  o[:csrf_tokens] = @csrf_patterns
  o[:csrf_request_ids] = @csrf_ids
  o[:csrf_requests] = csrf_requests
  o[:update_csrf_tokens] = @csrfToken.checked?
  o[:use_orig_request] = @useOriginalRequest.checked?
  o[:detect_logout] = @detectLogout.checked?
  o[:follow_redirect] = @followRedirects.checked?
  puts o.to_yaml if $DEBUG
  o
end