Class: SkypeAPI::OS::Mac

Inherits:
Object
  • Object
show all
Defined in:
lib/skypeapi/os/mac.rb

Defined Under Namespace

Classes: Server

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_application_name = 'ruby4skype') ⇒ Mac

Returns a new instance of Mac.

Raises:

  • (Skype::Error::NotImplement)


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/skypeapi/os/mac.rb', line 39

def initialize client_application_name='ruby4skype'
  raise Skype::Error::NotImplement
  
  @server = Server.alloc.init
  @server.instance_variable_set :@upper, self
  @server.instance_variable_set :@client_application_name, @client_application_name
  OSX::SkypeAPI.setSkypeDelegate @server
  
  @notify = Hash.new
  @event = Hash.new do |h,k|
    h[k] = Array.new
  end
  
  @attached = false
  Thread.new do
    OSX::NSRunLoop.currentRunLoop.run
  end
end

Instance Attribute Details

#attachedObject (readonly)

Returns the value of attribute attached.



58
59
60
# File 'lib/skypeapi/os/mac.rb', line 58

def attached
  @attached
end

Instance Method Details

#attachObject



60
61
62
# File 'lib/skypeapi/os/mac.rb', line 60

def attach
  OSX::SkypeAPI.connect
end

#attach_waitObject



64
65
66
67
68
69
70
# File 'lib/skypeapi/os/mac.rb', line 64

def attach_wait
  self.attach
  loop do
    break if @attached
    sleep 0.123
  end
end

#dettachObject



72
73
74
# File 'lib/skypeapi/os/mac.rb', line 72

def dettach
  OSX::SkypeAPI.disconnect
end

#invoke_block(cmd, waitLimit = WAIT_CMD_LIMIT) ⇒ Object



92
93
94
# File 'lib/skypeapi/os/mac.rb', line 92

def invoke_block cmd, waitLimit = WAIT_CMD_LIMIT
  res = invoke_prototype cmd
end

#invoke_callback(cmd, cb = Proc.new) ⇒ Object



87
88
89
90
# File 'lib/skypeapi/os/mac.rb', line 87

def invoke_callback cmd,cb=Proc.new
  res = invoke_prototype cmd
  cb.call res
end

#invoke_prototype(cmd) ⇒ Object



80
81
82
83
84
85
# File 'lib/skypeapi/os/mac.rb', line 80

def invoke_prototype cmd
  res = OSX::SkypeAPI.sendSkypeCommand(cmd)
  @queue.push(proc{do_event(:sent, cmd)}) if exist_event? :sent
  @queue.push(proc{do_event(:received, res)}) if exist_event? :received
  return res
end

#skype_runnging?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/skypeapi/os/mac.rb', line 76

def skype_runnging?
  OSX::SkypeAPI.isSkypeRunnging
end