Class: Skype::OS::Linux

Inherits:
Abstruct show all
Defined in:
lib/skype/os/linux.rb

Defined Under Namespace

Classes: Notify

Instance Method Summary collapse

Methods inherited from Abstruct

#add_hook, #del_hook, #exist_hook?, #get_hook, #invoke, #message_polling

Constructor Details

#initialize(app_name, service_name = "org.ruby.service") ⇒ Linux

Returns a new instance of Linux.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/skype/os/linux.rb', line 16

def initialize app_name, service_name="org.ruby.service"
  super()
  
  @app_name = app_name
  @queue = Queue.new
  
  @bus = DBus.session_bus
  notify = Notify.new("/com/Skype/Client")
  notify.instance_variable_set(:@os, self)
  ex_service = @bus.request_service(service_name)
  ex_service.export(notify)
  service = @bus.service 'com.Skype.API'
  @invoker = service.object '/com/Skype'
  @invoker.default_iface = 'com.Skype.API'
  @invoker.introspect
end

Instance Method Details

#attachObject Also known as: attach_wait



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/skype/os/linux.rb', line 42

def attach
  invoke "NAME #{@app_name}"
  invoke "PROTOCOL 9999"
  if @first_attached
    #@queue.push proc{do_hook :attached}
  else
    #@queue.push proc{do_hook :reattached}
  end
  Thread.new do
    l = DBus::Main.new
    l << @bus
    l.run
  end
end

#closeObject



108
109
110
111
# File 'lib/skype/os/linux.rb', line 108

def close
  queue.push :exit
  
end

#invoke_callback(*args) ⇒ Object



68
69
70
# File 'lib/skype/os/linux.rb', line 68

def invoke_callback *args
  raise Skype::Error::NotImprement
end

#invoke_prototype(cmd) ⇒ Object Also known as: invoke_block



59
60
61
62
63
64
# File 'lib/skype/os/linux.rb', line 59

def invoke_prototype(cmd)
  #@queue.push proc{do_hook :sent, cmd}
  res = @invoker.Invoke(cmd)[0]
  #@queue.push proc{do_hook :received, res}
  return res
end

#messageloopObject



76
77
78
79
80
# File 'lib/skype/os/linux.rb', line 76

def messageloop
  while callback = queue.shift
    break unless message_process callback
  end
end

#messagepollingObject



82
83
84
85
# File 'lib/skype/os/linux.rb', line 82

def messagepolling
  return message_process(queue.shift) unless queue.empty?
  return true
end

#push_queue(res) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/skype/os/linux.rb', line 95

def push_queue res
  p res
  #queue.push(proc{do_hook(:received, res)})
  
  if res == 'CONNSTATUS LOGGEDOUT'
    @attached = false
    #queue.push(proc{do_hook(:detached)})
    #Skype.attach
  end
      
  queue.push(proc{notify_selector.call res}) if notify_selector
end

#set_notify_selector(block = Proc.new) ⇒ Object



36
37
38
# File 'lib/skype/os/linux.rb', line 36

def set_notify_selector block=Proc.new
  @notify_selector = block
end

#start_messageloopObject



72
73
74
# File 'lib/skype/os/linux.rb', line 72

def start_messageloop
  Thread.new{messageloop}
end