Class: Skype::OS::MessageHandler
- Inherits:
-
SWin::Window
- Object
- SWin::Window
- Skype::OS::MessageHandler
- Defined in:
- lib/skype/os/window_messagehandler.rb
Instance Method Summary collapse
- #attach ⇒ Object
- #del_send_buffer(num) ⇒ Object
- #init(skypeAPI, queue) ⇒ Object
- #invoke(num, cmd) ⇒ Object
- #msghandler(sMsg) ⇒ Object
- #send_buffer ⇒ Object
Instance Method Details
#attach ⇒ Object
22 23 24 25 26 27 |
# File 'lib/skype/os/window_messagehandler.rb', line 22 def attach unless PostMessage.call(HWND_BROADCAST, @dwDiscoverMsg, hWnd, 0) raise Skype::Error::Attach.new("SkypeControlAPIDiscover broadcast failure") end return true end |
#del_send_buffer(num) ⇒ Object
33 34 35 |
# File 'lib/skype/os/window_messagehandler.rb', line 33 def del_send_buffer num @send_buffer.delete num end |
#init(skypeAPI, queue) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/skype/os/window_messagehandler.rb', line 5 def init skypeAPI, queue @skypeAPI = skypeAPI @queue = queue @dwDiscoverMsg = RegisterWindowMessage.call("SkypeControlAPIDiscover"); raise Skype::Error::Attach.new("SkypeControlAPIDiscover nothing") unless @dwDiscoverMsg @dwAttachMsg = RegisterWindowMessage.call("SkypeControlAPIAttach") raise Skype::Error::Attach.new("SkypeControlAPIAttach nothing") unless @dwAttachMsg addEvent(WM_COPYDATA) addEvent(WM_USER_MSG) addEvent @dwAttachMsg create unless alive? end |
#invoke(num, cmd) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/skype/os/window_messagehandler.rb', line 37 def invoke num, cmd unless @hSkypeWindowHandle raise Skype::Error::Attach.new("NullPointerException SendSkype!") return false end cmd = '#' + num.to_s + ' ' + cmd + "\0" pCopyData = application.arg2cstructStr("LLS",0,cmd.length+1,cmd) send_buffer[num] = cmd unless PostMessage.call(hWnd, WM_USER_MSG, @hSkypeWindowHandle, pCopyData) @hSkypeWindowHandle = nil raise Skype::Error::Attach.new("Skype not ready") end @queue.push_hook(:sent, cmd.chop) if @queue.exist_hook? :sent return true end |
#msghandler(sMsg) ⇒ Object
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 |
# File 'lib/skype/os/window_messagehandler.rb', line 54 def msghandler(sMsg) case sMsg.msg when @dwAttachMsg case sMsg.lParam when SKYPECONTROLAPI_ATTACH_SUCCESS @hSkypeWindowHandle = sMsg.wParam invoke_protocol @queue.push_hook(:attach,:success) unless @skypeAPI.attached if @skypeAPI.first_attached @queue.push_hook(:attached) else @queue.push_hook(:reattached) end end @skypeAPI.attached = true @skypeAPI.first_attached = false when SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION @queue.push_hook(:attach,:authorize) @queue.push_hook(:authorize) when SKYPECONTROLAPI_ATTACH_REFUSED @queue.push_hook(:attach,:refused) @queue.push_hook(:refused) @skypeAPI.attached = false when SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE @queue.push_hook(:attach, :not_available) @queue.push_hook(:not_available) @skypeAPI.attached = false when SKYPECONTROLAPI_ATTACH_API_AVAILABLE @queue.push_hook(:attach, :available) @queue.push_hook(:available) else @queue.push_hook(:attach,:unkown) @queue.push_hook(:unkown) end sMsg.retval = 1 when WM_COPYDATA if sMsg.wParam == @hSkypeWindowHandle retval = application.cstruct2array(sMsg.lParam,"LLL") cmd = application.pointer2string(retval[2],retval[1]) @queue.push cmd sMsg.retval = 1 end when WM_USER_MSG unless SendMessage.call(sMsg.wParam, WM_COPYDATA, sMsg.hWnd, sMsg.lParam) raise Skype::Error::Attach.new("Skype not ready") end sMsg.retval = 1 else super end end |
#send_buffer ⇒ Object
29 30 31 |
# File 'lib/skype/os/window_messagehandler.rb', line 29 def send_buffer @send_buffer ||= Hash.new end |