Class: Idb::CycriptThread

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CycriptThread

Returns a new instance of CycriptThread.



9
10
11
12
13
14
15
16
# File 'lib/gui/cycript_thread.rb', line 9

def initialize *args
  super *args
  $terminate_cycript_thread = false
  @queue = Queue.new



end

Instance Attribute Details

#channelObject

Returns the value of attribute channel.



7
8
9
# File 'lib/gui/cycript_thread.rb', line 7

def channel
  @channel
end

Instance Method Details

#launch_processObject



30
31
32
33
34
35
36
37
38
39
40
41
42
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
# File 'lib/gui/cycript_thread.rb', line 30

def launch_process

     @channel = $device.ssh.open_channel do |ch|
      channel.request_pty do |ch, success|
        raise "Error requesting pty" unless success
        ch.exec("export TERM=vt220; stty -echo -icanon; cycript -p SpringBoard") do |ch, success|
          raise "Error opening shell" unless success

          ch.on_extended_data do |ch, type, data|
            STDOUT.print "Error: #{data}\n"
          end

          ch.on_data do |ch, data|
            puts "emitting"
            emit new_entry(data)
            puts "done"
          end

          ch.on_close { |ch|
            $log.info "cycript terminated"
          }


        end
      end
     end


      puts "thred"
    @abc = Thread.new do
    loop do
      #TODO mutex to protect device?
      #even better: make one central thread that calls process.
      # and all functions using it call it to ensure its running. or auto start it.
      sleep 0.5
      puts "loop"
      $device.ssh.loop 0.1
      puts "done"
      if $terminate_cycript_thread
        $log.info "Terminating cycript"
        channel.close
        break
      end
    end
    $log.info "Terminating thread"
  end


end

#send_data(data) ⇒ Object



18
19
20
21
22
23
# File 'lib/gui/cycript_thread.rb', line 18

def send_data data
  puts "sending data"
#  @queue << data
  @channel.send_data data
  #      @channel.send_data "testtest\n"
end

#stopObject



26
27
28
# File 'lib/gui/cycript_thread.rb', line 26

def stop
  $terminate_cycript_thread = true
end