Class: Idb::CacheDbWidget

Inherits:
Qt::Widget
  • Object
show all
Defined in:
lib/gui/cache_db_widget.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CacheDbWidget

Returns a new instance of CacheDbWidget.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/gui/cache_db_widget.rb', line 4

def initialize *args
  super *args

  @refresh = Qt::PushButton.new "Refresh"
  @refresh.connect(SIGNAL :released) {
    refresh
  }

  @list = Qt::ListWidget.new self
  @list.connect(SIGNAL('itemDoubleClicked(QListWidgetItem*)')) { |item|
  #      x = ConsoleLauncher.new
    #TODO: find sqlite binary
    #x.run "/usr/bin/sqlite3 #{Dir.getwd}/#{$selected_app.cache_file item.full_path}"

    cache_name = $selected_app.cache_file item.full_path
    if cache_name.nil?
      $log.error "File #{item.full_path} could not be downloaded. Either the file does not exist (e.g., dead symlink) or there is a permission problem."
    else
      if RbConfig::CONFIG['host_os'] =~ /linux/
        Process.spawn "'#{$settings['sqlite_editor']}' '#{cache_name}'"
      else
        Process.spawn "open -a '#{$settings['sqlite_editor']}' '#{cache_name}'"
      end
    end

  }
 # "Launch app"

  layout = Qt::VBoxLayout.new do |v|
    v.add_widget(@list)
    v.add_widget(@refresh)
  end
  setLayout(layout)
end

Instance Method Details

#clearObject



39
40
41
# File 'lib/gui/cache_db_widget.rb', line 39

def clear
  @list.clear
end

#refreshObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/gui/cache_db_widget.rb', line 44

def refresh
  @list.clear
  cache_dbs = $selected_app.find_cache_dbs
  cache_dbs.each { |full_path|
    item = PathListWidgetItem.new
    if $device.simulator?
      item.setText full_path.sub($selected_app.app_dir,'')
    else
      pc = $device.protection_class full_path
      if full_path.start_with? $selected_app.app_dir
        item.setText "[App Bundle]" + full_path.sub($selected_app.app_dir,'') + " => " + pc.strip
      elsif full_path.start_with? $selected_app.data_dir
        item.setText "[Data Dir]" + full_path.sub($selected_app.data_dir,'') + " => " + pc.strip
      end
    end
    item.full_path = full_path
    @list.addItem item
  }
end